Comprehensive Guide for proxy settings for Chrome

If you work in a large enterprise or use chrome in a school, chances are Google Chrome access the Internet through a proxy server.


What is a proxy server? It is simply an intermediary between two machines that want to communicate with each other: Google Chrome on your laptop and the web server hosting websites on the Internet. The more important question is, why use a proxy server? Some of the reasons are:

  • Security: only safe websites are allowed and unsafe or inappropriate websites are blocked
  • Limit access: only devices that are allowed to have Internet access can connect to the proxy server
  • Accountability: know who is accessing what resources
  • Speed: proxy servers used in conjunction with caching server can speed up access

Chrome Proxy Settings

Once upon a time, setting proxy server settings is straightforward. For example, in Internet explorer, go to Internet Options and insert the proxy address.


This used to be the case for Chrome, until it changed to using the Operating Systems' proxy settings


So Chrome does not automatically set the proxy, but you use your Operating System's proxy settings.


Windows Proxy Settings

Windows 10 has a new proxy Settings.


But the legacy Internet Options settings is still valid - check that nothing is set there.


Windows also reads the HTTP_PROXY and HTTPS_PROXY environment variable. If you find that you have no proxy settings enabled but Chrome is still acting weird, check for these environment variables.




macOS Proxy Settings

You can set proxy server details in System Preferences


You can set the proxy settings from command line too


networksetup -setwebproxy "Wi-fi" 127.0.0.1 8080
networksetup -setwebproxystate "Wi-fi" on
networksetup -getwebproxy "Wi-Fi"




And for SOCKS proxy


networksetup -setsocksfirewallproxy wi-fi localhost 1080
networksetup -setsocksfirewallproxystate "Wi-Fi" on
networksetup -getsocksfirewallproxystate "Wi-Fi"




Linux Proxy Settings

The best way to set proxy is to use environment variables, so that the settings is applied to all applications, including those started from the command line


http_proxy=http://myproxy.server.com:8080/
https_proxy=http://myproxy.server.com:8080/
all_proxy=http://myproxy.server.com:8080/
no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"



GNOME Proxy Settings

If you are using a Linux distribution that is running GNOME (for example: Ubuntu, CentOS and RHEL), the proxy settings is controlled from gsettings. You will need to use these commands


gsettings set org.gnome.system.proxy.http host "myproxy.server.com"
gsettings set org.gnome.system.proxy.http port "3128"




SOCKS vs HTTP

HTTP proxies are clear enough: you want to access websites over http/https, and HTTP proxy servers simply relay the requests across. But it also means you need to make changes to firewall rules to open up a new port for the proxy server.

The SOCKS protocol is designed to work at a lower level, without opening additional ports. For example, ssh natively support SOCKS for port forwarding, i.e. SSH tunneling.

The tricky bit is how to set SOCKS proxy. Instead of


http_proxy=http://myproxy.server.com:8080/



append socks5 in front of the SOCKS server address


http_proxy=socks://127.0.0.1:1080



Likewise in Windows 10 proxy settings, add the prefix socks=




Proxychains

What if the application you are using does not work with SOCKS protocol? You can use Proxychains to redirect the remote SOCKS/HTTP proxy to your application. For example


$ proxychains4 brew install zsh
[proxychains] config file found: /home/hanxuel.linuxbrew/etc/proxychains.conf




More details in this article.


Proxy Chaining

Perhaps the remote proxy uses PAC / WPAD to configure a list of URLS. Or the remote proxy server is very simple, and you want to have fine-grained control over what URLs to go through the proxy server, and what URLs to access directly. pacproxy is the perfect tool.


Start Chrome with Command Line Options

You can also explicitly tell Chrome to use proxy settings by starting Chrome from the command line.  For example:

google-chrome --proxy-server=socks://127.0.0.1:9999

Note that Chrome ignores any local host inclusion for using proxy for security reasons. Explained in more detail here. If you must include local addresses, use the <-loopback> option


google-chrome --proxy-server=socks://10.10.110.28:8080 --proxy-bypass-list=<-loopback>










1 comment: