Carlos Vargas

Configuring Web Proxy on Linux

Blog Post created by Carlos Vargas on Aug 2, 2016

This guide is to help you configure your Enterprise proxy setting in your Linux Servers. This servers can be used to host native apps or containers. The guide include the settings to two of the most predominant flavors of Linux CentOS/RHEL and Ubuntu.

CentOS/RHEL

Environment

To configure your system-wide proxy settings  add the following lines to your /etc/environment file:

vi /etc/environment
http_proxy=”http://1.2.3.4:8080/”
https_proxy=”https://1.2.3.4:8080/”
ftp_proxy=”ftp://1.2.3.4:8080/”
socks_proxy=”socks://1.2.3.4:8080″
no_proxy=”192.168.1.0/24,*.local,.containerking.ninja,server1,server2″

To apply these settings without restarting the machine run the following commands on the bash shell:

YUM

To configure your YUM package manager edit the /etc/yum.conf file:

vi /etc/yum.conf
proxy=http://proxysrv:8080

Ubuntu

Environment

To configure your system-wide proxy settings  add the following lines to your Edit /etc/profile

sudo vi /etc/profile
#Proxy
export http_proxy=http://1.2.3.4:8080

export socks_proxy=socks://1.2.3.4:8080
export https_proxy=http://1.2.3.4:8080
export ftp_proxy=http://1.2.3.4:8080
export no_proxy=localhost,127.0.0.0/8,127.0.1.1,127.0.1.1/*,”192.168.1.0/24,*.local,.containerking.ninja,server1,server2″

Apt-Get

To configure your apt-get package manager proxy settings edit the /etc/apt/apt.conf

sudo vi /etc/apt/apt.conf
Acquire::http::Proxy “http://1.2.3.4:8080”;

visudo

To keep the settings across sudo sessions add this line under to your /etc/sudoers file

sudo visudo
Defaults env_keep += “http_proxy https_proxy ftp_proxy socks_proxy no_proxy”

 

Reference:

Configuring Web Proxy on Linux – Container King

Hitachi Developer Network

Outcomes