• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Configure Proxy in CentOS/RHEL/Fedora

by admin

What is a Proxy Server

A proxy server is a server that acts as an intermediary for requests from clients seeking resources on the internet or an external network. Think of it as a go-between who makes requests on behalf of the client, ensuring that anyone outside of your network does not know the details of the requesting host.

Verify if proxy is set on the server

This command will show if there is a proxy server configured on the system:

# echo $http_proxy

Setting Proxy for Command line programs

The http_proxy environment variable is used to specify proxy settings to client programs such as curl and wget. Below are the various examples of using proxy for commandline programs:

1. No username and password required:

To configure proxy without username and password:

# export http_proxy=http://SERVER:PORT/

2. Username and password authentication:

To configure the proxy server with username and password authentication:

# export http_proxy=http://USERNAME:PASSWORD@SERVER:PORT/

3. Domain, username and password required:

To configure proxy with username/password authentication along with the Domain name:

# export http_proxy=http://DOMAIN\\USERNAME:PASSWORD@SERVER:PORT/

Special character handling

Literal backslash characters (\) need to be doubled escape them as shown below.

# export http_proxy=http://DOMAIN\\USERNAME:PASSWORD@SERVER:PORT/

When the username or password uses the @ symbol, add a backslash (\) before the @ – for example:

# export http_proxy=http://DOMAIN\\USERN\@ME:PASSWORD@SERVER:PORT

or

# export http_proxy=http://DOMAIN\\USERNAME:P\@SSWORD@SERVER:PORT

Configuring Proxy in CentOS/RHEL 7 permanently (for processes without shell)

Define the environment variables in /etc/environment file if you want to add a permanent proxy in the CentOS/RHEL 7.

# echo "http_proxy=http://proxy.example.com:3128/" > /etc/environment

Note that unlike a shell script in /etc/profile.d described in the next section, the /etc/environment file is NOT a shell script and applies to all processes without a shell.

Configuring proxy for processes with SHELL

For bash and sh users, add the export line given above into a new file called /etc/profile.d/http_proxy.sh file:

# echo "export http_proxy=http://proxy.example.com:3128/" > /etc/profile.d/http_proxy.sh

For csh and tcsh users, use the following command to set the http_proxy variable in a new file called /etc/profile.d/http_proxy.csh file:

# echo "setenv http_proxy http://proxy.example.com:3128/" > /etc/profile.d/http_proxy.csh

The extension of these files determines which shell will read them. The commands are not interchangeable.

Setting proxu for other programs

To configure yum behind proxy, modify the /etc/yum.conf with the following:

# vi /etc/yum.conf
proxy=http://proxy.example.com:3128 
proxy_username=yum-user 
proxy_password=qwerty
Note: Other programs (such as Firefox) will have their own internal settings for proxy usage.
How to use wget to download file via proxy
How to configure docker to use proxy

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, Fedora, Linux

Some more articles you might also be interested in …

  1. kdocker: command not found
  2. free: command not found
  3. How to Delete Duplicate Rules in Routing Policy Database in CentOS/RHEL
  4. chsh Command Examples in Linux
  5. pacstall Command Examples
  6. lsof : Most commonly used examples
  7. Linux OS Service ‘kdump’
  8. ifrename: command not found
  9. ping: command not found
  10. How to Kill VNC Window Sessions in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • pw-cat Command Examples in Linux
  • pvs: command not found
  • pulseaudio: command not found
  • pulseaudio Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright