Using a Proxy with your Raspberry Pi

This is the steps we have followed so that we can get our school Raspberry Pi computers to run behind our school proxy without too many issues:

  1. Configure an apt-cacher NG server to handle your apt-get updates – See this post for more details
  2. Whitelist the Python PIP domains and use the –proxy:server:port configuration when installing with PIP – See this post for more details
  3. Open UDP port 123 and TCP port 9418 for the IP range of your devices on the school firewall so that they can use GIT and NTP without issue
  4. Create a new desktop launcher for Chromium so that it auto-detects your school network proxy (this is assuming you are pushing your proxy servers .pac file out via DHCP and/or DNS!) – The guide for this part is detailed below…

If you run chromium-browser –help you will see something like this:

--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="socks4://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 dif‐
 ferent 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".

--no-proxy-server
 Disables the proxy server. Overrides any environment variables
 or settings picked via the options dialog.

--proxy-auto-detect
 Autodetect proxy configuration. Overrides any environment vari‐
 ables or settings picked via the options dialog.

The setting we are interested in is the –proxy-auto-detect You can test that this works with your school’s proxy server by running chromium-browser –proxy-auto-detect on the terminal of your Raspberry Pi. Chromium should launch and then when you visit an external website you should be asked to log into your proxy server. Log in with your school’s network credentials and you should now be browsing …

This is all well and good, but we can’t really expect our students to remember to launch Chromium from the terminal in this fashion every time they need to browse…

So we are going to create a new application launcher for our proxy auto-detecting version of Chromium. Enter these four commands below into your terminal to start editing your new Chromium application launcher.

cd /usr/share/raspi-ui-overrides/applications
sudo cp ../../applications/chromium-browser.desktop ./
sudo mv ./chromium-browser.desktop ./chromium-browser-proxy.desktop 
sudo nano chromium-browser-proxy.desktop

In Nano edit the following:

line 3: Name=Chromium Web Browser – Auto Proxy – I only changed the English version here; if you are a linguist you could change the other translations too!

Find all lines beginning Exec and add –proxy-auto-detect to the end of the command line. My complete updated file is shown below.

Save and close the file. You should now have a new entry in your menu for your proxy version of Chromium! You can then add this new application launcher to your panels or desktop. As we added it to the raspi-ui-overrides as a new application any updates to the original Chromium application launcher should affect this modified one!

 

Leave a Reply

Your email address will not be published. Required fields are marked *