Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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=""

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 – tuananh Jul 19 '13 at 19:40

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.
  • Add the following lines, modifying appropriately. You must duplicate in both upper-case and lower-case because (unfortunately) some programs only look for one or the other:

  • 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 "";
    Acquire::ftp::proxy "";
    Acquire::https::proxy "";   

Finally, logout and reboot to make sure the changes take effect.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .