Take the 2-minute tour ×

I've set up a squid forward proxy to cache all internet requests. I have a public ip and opened port 3128. Now I just need to set my ubuntu server to force all internet connections to pass through this proxy, using the ip address and port number.

I know this command which will make ubuntu access the internet via a proxy, but I was told it wasn't permanent.

export http_proxy="http://proxy.example.com:8080"

Which command do I need to use to force ubuntu to go through this proxy regardless of reboots or sessions?


share|improve this question
Put that line into your ~/.bash_profile –  hvtuananh Jul 19 '13 at 19:40
add comment

1 Answer

You have to set some settings in /etc/environment to make it permanent:

  • Open the /etc/environment file with vi (or your favorite editor). This file stores the system-wide variables initialized upon boot.

  • apt-get, aptitude, etc. will not obey the environment variables when used normally with sudo. So separately configure them; create a file called 95proxies in /etc/apt/apt.conf.d/, and include the following:

     Acquire::http::proxy "http://myproxy.server.com:8080/";
    Acquire::ftp::proxy "ftp://myproxy.server.com:8080/";
    Acquire::https::proxy "https://myproxy.server.com:8080/";   


share|improve this answer
Right, I've performed all of the steps and added the settings. However CGI scripts seem to ignore the rules. What do I need to do to have CGI scripts also obey them? –  jc.yin Jul 19 '13 at 19:53
Do you have logged out and in after you changed it? –  donothingloop Jul 19 '13 at 19:57
Well I've rebooted the server.. so shouldn't that mean I've logged in and out? But still CGI scripts that make internet connections outside seem to ignore the environment wide rules –  jc.yin Jul 19 '13 at 22:17
add comment

Your Answer


