Post

Configure CentOS / RedHat 7 to Use a Proxy

Configure CentOS / RedHat 7 to Use a Proxy

Configuring Proxy Settings in CentOS/RHEL 7

This guide explains how to set up system-wide proxy settings for CentOS or Red Hat Enterprise Linux 7.

Setting Global Proxy Configuration

Step 1: Edit the Global Profile File

Open the global profile configuration file:

1
sudo vi /etc/profile

Step 2: Add Proxy Environment Variables

Add the following lines to the end of the file:

1
2
3
4
5
6
7
8
9
10
11
12
13
# Define your proxy URL once for easy updating
MY_PROXY_URL="https://proxyserver:portnumber/"

# Set up proxy environment variables (both uppercase and lowercase)
HTTP_PROXY=$MY_PROXY_URL
HTTPS_PROXY=$MY_PROXY_URL
FTP_PROXY=$MY_PROXY_URL
http_proxy=$MY_PROXY_URL
https_proxy=$MY_PROXY_URL
ftp_proxy=$MY_PROXY_URL

# Export all variables
export HTTP_PROXY HTTPS_PROXY FTP_PROXY http_proxy https_proxy ftp_proxy

Example Configuration

For a proxy server at proxy.dsc.local on port 8080:

1
MY_PROXY_URL="https://proxy.dsc.local:8080/"

Applying the Changes

After saving the file, you can apply the changes by:

1
2
3
4
# For the current session
source /etc/profile

# Or log out and log back in

Additional Proxy Configurations

For YUM Package Manager

To configure YUM to use the proxy:

1
sudo vi /etc/yum.conf

Add the following line:

1
proxy=https://proxy.dsc.local:8080/

For wget

Create or edit ~/.wgetrc:

1
vi ~/.wgetrc

Add:

1
2
3
4
use_proxy=yes
http_proxy=https://proxy.dsc.local:8080/
https_proxy=https://proxy.dsc.local:8080/
ftp_proxy=https://proxy.dsc.local:8080/

For curl

Create or edit ~/.curlrc:

1
vi ~/.curlrc

Add:

1
proxy=https://proxy.dsc.local:8080/
This post is licensed under CC BY 4.0 by the author.