Please login or register to participate.
Wiki Page

Setup to use an HTTP Proxy Server


Setting up to use a proxy server for Internet will automatically use the proxy server that is setup on the server Linux environment. In Linux, the existence of a proxy server is determined by the presence of two environment variables:

  • http_proxy
  • https_proxy

These environment variables can be setup in various places depending on whether we want the proxy settings to apply system-wide or only for a particular user. Since we want to always have the proxy settings to be available, we recommend applying these two environment variables system-wide, but depending on your scenario you may choose to apply them only for your particular user login.

System-wide proxy settings

To apply proxy settings for the full linux system, the recommended place to apply the environment settings is in the /etc/profile file.

This file is loaded for all logins, interactive and non-interactive and this is where we will add the necessary environment variables.

  • On the command line prompt of the ISO CD appliance, use the su command to get root command line access. (Your command line prompt will change from the $ sign to the # sign).
  • nano /etc/profile
  • Add the following 2 lines to the bottom of the file:
export http_proxy="http://username:password@proxyserverhostorip:port/"
export https_proxy="http://username:password@proxyserverhostorip:port/"

Replace the parts in the above 2 lines using the following legend:

  • username: Replace this with the actual username you want to use the proxy server with.
  • password: Replace this with your actual proxy server password
  • proxyserverhostorip: Replace this with the hostname or IP address of your proxy server.
  • port: Replace this with the port number of the proxy server. If your proxy server accepts http proxy connections at port 3128 then replace port with 3128. If you don't know what the port number is, or no number was supplied to you, then it is possible that the proxy server accepts connections at the default port, which means that you must supply 80 as the port for http or 443 as the port for https. Supplying a port number is required!

In case you don't have a proxy server for proxying HTTPS traffic, do not add the second line.

In case you don't have authenticated access, and proxy server access is available without a password, eliminate the entire username:password@ part. So your line will look something like this:

export http_proxy="http://proxyserverhostorip:port/"

Once you have edited the /etc/profile file as above, you need to restart the system to bring the setting into effect.

You can do this while you're escalated to the # commandline with the reboot command, or follow whatever regular procedure you have for rebooting the server.

Once the reboot has completed, you can test that the proxy server settings have "taken" by opening up a command line, and using the wget command, to get any URL of your choice. Example:
cd /tmp

Proxy settings for a single user

Note that while this can cause inconsistencies with the way the init.d daemon or other system services "see" the environment variables, it is sometimes necessary to setup the proxy settings for only a particular user or to promote each linux user to have their own authenticated proxy server access. To be able to do this, instead of editing the system /etc/profile file, you can achieve the same effect for any user by editing the .profile file in their folder, or the .bashrc file as well. The same syntax and legend works, you just have to put the environment variable setting in the user's area instead of system-wide. You can refer to any of the following guides / posts to figure out how to set it up:

Describes how can be setup to use an HTTP Proxy Server to access the Internet, instead of expecting a direct Internet connection.
Comments (3)
macagua Jun 01, 2010 09:05 PM
Now i have a general instruction for Apache 2 and Nginx Web Server at the bellow link [0], of course in Spanish ;) but the English reference are at the bottom page Wiki :P

[0] http://wiki.canaima.softwar[…]Reescritura_de_Servidor_Web
sumo Jun 05, 2010 07:20 AM
My set up doesn't have direct internet connection. How do I use HTTP proxy server ?
sumo Jun 07, 2010 12:30 PM
I managed to solve the problem. I have modified /etc/profile file to have following statement

export http_proxy="http://serverip:port"