coolblue2000
Posts: 30
Joined: Tue Jan 08, 2013 9:48 am

How to set Proxy Address

Tue Jan 08, 2013 9:51 am

We have a pi for showing office stats etc on a nice big screen. However it can't connect to the internet as we need to set a proxy address for it. How do I do this?

User avatar
penguintutor
Posts: 401
Joined: Tue May 08, 2012 9:11 am
Location: UK

Re: How to set Proxy Address

Tue Jan 08, 2013 11:37 pm

You can set a proxy through the environment variables http_proxy, https_proxy, ftp_proxy and no_proxy etc.

You can put these into /etc/profile (or if you prefer /etc/environment) to take effect system-wide.

eg. add the following lines to the bottom of /etc/profile

Code: Select all

export http_proxy="http://<proxyipaddress>:<proxyport>"
export https_proxy="http://<proxyipaddress>:<proxyport>"
export no_proxy="localhost,127.0.0.1,192.168.0.0/16"
inserting the addresses / ports as appropriate.

Not every application will honour these, but most well designed apps do. Notably the Midori browser will honour the proxy statements (as long as enabled in the preferences), but ignores the no_proxy settings :-(

Some applications allow you to configure the proxy manually - eg. midori preferences are reached through the down arrow near the top right > Menu > Preferences > Network. Here you can choose between using the environment settings, manual proxy or no proxy.

coolblue2000
Posts: 30
Joined: Tue Jan 08, 2013 9:48 am

Re: How to set Proxy Address

Wed Jan 09, 2013 10:29 am

I have set the proxy in etc/environment but apt still hangs and can't connect to the web.

If I use sudo apt-get -o Acquire::http::proxy 111.111.11.11:8080 update. Everything works fine so the proxy is working, apt just is not pulling the settings. How do I get apt working?

User avatar
penguintutor
Posts: 401
Joined: Tue May 08, 2012 9:11 am
Location: UK

Re: How to set Proxy Address

Wed Jan 09, 2013 2:55 pm

When using sudo the environment variables are normally reset as a security feature
Try adding the -E option to sudo to preserve your environment variables

eg.

Code: Select all

 sudo -E apt-get update
to change this permanently you could either edit the sudoers file (visudo) and put the following in place of the current entry:

Code: Select all

Defaults !env_reset
or perhaps a better way is to explicitly keep the proxy entries - eg. add entry

Code: Select all

Defaults        env_keep += "http_proxy"

JPB-HK
Posts: 56
Joined: Thu Nov 22, 2012 5:00 pm

Re: How to set Proxy Address

Thu Jan 10, 2013 3:15 am

To get apt-get to work with a proxy every time, I did the following:

Code: Select all

sudo nano /etc/apt/apt.conf
# Add following line to file:
Acquire::http::Proxy “http://xxx.xxx.xxx.xxx:8080/”;Acquire::ftp::Proxy “ftp://xxx.xxx.xxx.xxx:8080/”;
John
NCR 310 - ZX81 - Apple II+ - Dell/Intel - Mac mini... Raspberry Pi!

Return to “Beginners”