Manually configuring proxy settings of Google Chrome on Ubuntu

9

6

I have an application that needs to change the proxy settings used by Google chrome, then use the browser and then automatically switch back the proxy to what it was.

I have been unable to find where on my Ubuntu system are these settings stored. Its not in the Preferences file for sure. Any ideas on how to go about this task?

Elitecoder

Posted 2011-08-11T09:54:39.223

Reputation: 91

Looks like you want to *programmatically* change the proxy settings. Changing them manually would involve opening up the Preferences section of the Chrome browser. What you want to do seems very strange -- what is the underlying goal of what you're trying to accomplish? There may be a simpler way of achieving that goal. – Mike Rowave – 2011-08-11T13:12:48.877

May be explaining why I wish to perform such a thing will help people offer alternate solutions. I wish to record all the traffic being served by Google Chrome. For that, I have a client who acts like a proxy server. Now, if I set the proxy of Chrome to localhost and a certain port, all the traffic will go through my client and my client will be able to record all thats happened. And when I am done recording what I need, I will shutdown chrome and restore its original proxy settings.

I do not wish to use command line arguments passed onto Chrome browser and wish to do this programmatically. – Elitecoder – 2012-02-16T13:50:30.113

Answers

12

You can use the Chromium proxy settings from the command line. The man page tells you how. So here is an excerpt from man chromium-browser from my Ubuntu Natty:

   --proxy-server=host:port
          Specify the HTTP/SOCKS4/SOCKS5 proxy server to use for requests.  This overrides any environment variables or settings picked via the options dialog.  An individual
          proxy server is specified using the format:

            [<proxy-scheme>://]<proxy-host>[:<proxy-port>]

          Where <proxy-scheme> is the protocol of the proxy server, and is one of:

            "http", "socks", "socks4", "socks5".

          If the <proxy-scheme> is omitted, it defaults to "http". Also note that "socks" is equivalent to "socks5".

          Examples:

            --proxy-server="foopy:99"
                Use the HTTP proxy "foopy:99" to load all URLs.

            --proxy-server="socks://foobar:1080"
                Use the SOCKS v5 proxy "foobar:1080" to load all URLs.

            --proxy-server="sock4://foobar:1080"
                Use the SOCKS v4 proxy "foobar:1080" to load all URLs.

            --proxy-server="socks5://foobar:66"
                Use the SOCKS v5 proxy "foobar:66" to load all URLs.

          It is also possible to specify a separate proxy server for different URL types, by prefixing the proxy server specifier with a URL specifier:

          Example:

            --proxy-server="https=proxy1:80;http=socks4://baz:1080"
                Load https://* URLs using the HTTP proxy "proxy1:80". And load http://*
                URLs using the SOCKS v4 proxy "baz:1080".

The advantage of using the command line arguments is, that you do not have to change your global system settings.

For example:

$ chromium-browser --proxy-server="http://127.0.0.1:8080"

Also have a look at Justin's post in this thread where he describes how to use the proxy for DNS request also.

Strubbl

Posted 2011-08-11T09:54:39.223

Reputation: 570

1Is there a way to set specific domains which should NOT use proxy? Something analogous to the No proxy for setting in Firefox... – becko – 2014-08-20T14:49:03.543

1chrome doesn't work because it hasn't option --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE 127.0.0.1" – BeGood – 2017-05-26T04:46:43.420

https://askubuntu.com/questions/513840/google-chrome-proxy-settings – sancho.s Reinstate Monica – 2018-01-26T13:12:33.353

doesn't work. chrome ignores all proxy settings – user27636 – 2018-10-26T20:12:15.073

3

Strubbl's anwser is correct, this is the best solution, since you do not need to keep enabling/disabling system wide proxy settings.

I would add that you should also use this switch in conjunction

--host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE 127.0.0.1" 

where 127.0.0.1 is your proxy server. This switch stops chrome from making external dns requests, which when privacy is important will not leak any DNS info.

So the complete command is as follows.

/usr/bin/google-chrome-stable %U --proxy-server="socks5://127.0.0.1:9050" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE 127.0.0.1"

Justin

Posted 2011-08-11T09:54:39.223

Reputation: 31

1

For Ubuntu 14.04 LTS, go to the terminal. Open this file but save it first

& cp /usr/share/applications/chromium-browser.desktop /home/@user/

& sudo su

(passwd)

Then

& gedit /usr/share/applications/chromium-browser.desktop &

Go to the first "Exec" line

Exec=chromium-browser %U

Change it to

Exec=chromium-browser %U --proxy-server="127.0.0.1:8118"

127.0.0.1:8118 or what ever. Save this file and close the editor and start the browser again and try it.

To make this change back

& sudo su

(passwd)

& cp /home/@user/chromium-browser.desktop /usr/share/applications/

or rewrite this line to

Exec=chromium-browser %U

enjoy!

TheRabi71

Posted 2011-08-11T09:54:39.223

Reputation: 11

0

Chromium and Google Chrome use the http_proxy, https_proxy and no_proxy environment settings. Accessing these is different from programming language to programming language. In a shell, you can type

echo $http_proxy

etc. They can be set in a multitude of ways. See https://askubuntu.com/a/513956/438156 and https://askubuntu.com/a/755100/438156.

serv-inc

Posted 2011-08-11T09:54:39.223

Reputation: 400