Proxy

Raspberry Pi behind a proxy server

When you are in a cooperate building, or just at home where you have to connect to a proxy server to be able to connect to the internet or a separate network.
In this quick tutorial we’ll take a look on where you need to put these demn settings so you can update your Pi and access the internet behind your proxy server.

Know your Proxy

Before we can continue you need some basic info about your proxy.
Without these you can’t set up your raspberry pi.

  • Proxy server IP
  • Proxy server port
  • Proxy login (optional)
  • Proxy password (optional)

Note that a login and password might not be required for your proxy.

Setting up APT proxy

Setting up your raspberry pi to use the proxy for the package manager you can use the ‘/etc/apt/’ folder, open the proxy file and simply add your proxy settings.

sudo nano /etc/apt/apt.conf

Now what do we put in this file? simple your proxy address and port, for example:

Acquire::http::Proxy "http://192.168.10.10:8081";

DO NOT forget the semicolon on the end or you’ll get error’s of garbage at the end of the file.

In this example there was no need for login information, but if you need it for your proxy it’ll look like following:

Acquire::http::Proxy "http://username:[email protected]:proxyport/";

Save this file and restart you Pi, now you’ll be able to use APT behind your proxy

Setting up System wide proxy

When you also want internet access in chromium (or other browser/program) you’ll need a system wide proxy setting.
Note that APT ignores this setting.

Open the environment file

sudo nano /etc/environment

Add your proxy server in here.
you can chose between HTTP and HTTPS, i added both.

export http_proxy="http://192.168.10.10:8081"
export https_proxy="http://192.168.10.10:8081"
Environment proxy settings

As before, if your proxy requires login use following (use https if required)

export http_proxy="http://username:[email protected]:proxyport"

Now we need to add these settings to the sudoers file.
Why is this you ask? When you run a command as sudo that requires internet access it won’t use the proxy unless it is told to do so.
So lets add it, to do that we’ll open the visudo file

sudo visudo

Add the following line to the file so sudo will use the environment variables you just created:

Defaults    env_keep+="http_proxy https_proxy no_proxy"

Save the file and reboot your Pi.
You are now ready to use the proxy.

Leave a reply:

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.