Manually configuring proxy settings of Google Chrome on Ubuntu

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?


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'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"

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!