How to configure proxy in CentOS 7 and RHEL 7

In this tutorial we see, how to configure proxy in CentOS 7 and RHEL 7. We will also see proxy configuration through command line and yum.conf file. So let start and see proxy configuration in CentOS 7 and RHEL 7.

First of all we should know what is proxy server? So let’s explain it first.

What is Proxy Server

A proxy server intercepts all client requests, and provides responses from its cache or forwards the request to the real server. A client can request some service, such as a file, connection, web page, or other resource available from a different server and the proxy server evaluates the request as a way to simplify and control its complexity.

Verify proxy on your server before proxy setting

You can verify proxy on your system using echo command, if you have all ready proxy configured on your system. Like below:-

#echo $http_proxy
[[email protected] ~]# echo $http_proxy
[[email protected] ~]#

You can see we don’t have any proxy setting on our server in above screen shot.

Proxy Setting through Command line

The http_proxy environment variable is used to specify proxy settings to client programs such as curl and wget. You can see some proxy setting example in below through command line.

Configure proxy without username and password required

We can configure proxy without username and password like below:-

# export http_proxy=http://SERVER:PORT/
[[email protected] ~]# export http_proxy=
[[email protected] ~]#
[[email protected] ~]# echo $http_proxy
[[email protected] ~]#

You can see in above screen shot we have successfully set proxy server with port.

Remove proxy using unset commands

We can also remove proxy with unset command. Like below:-

[[email protected] ~]# unset http_proxy
[[email protected] ~]# echo $http_proxy
[[email protected] ~]#

You can see in above we have remove proxy through unset proxy commands.

Configure proxy with username and password authentication

You can also configure proxy with username and password authentication like below:-

# export http_proxy=http://USERNAME:[email protected]:PORT/
[[email protected] ~]# export http_proxy=http://urclouds:[email protected]:80
[[email protected] ~]# echo $http_proxy
http://urclouds:[email protected]:80
[[email protected] ~]#

You can see we have successfully set proxy with username and password in above screen shot.

Configure proxy with domain, username and password required option

We can configure proxy with username/password authentication along with the Domain name. Like below:-

# export http_proxy=http://DOMAIN\\USERNAME:[email protected]:PORT/
[[email protected] ~]# export http_proxy=http://test\\urclouds:[email protected]:80
[[email protected] ~]# echo $http_proxy
http://test\urclouds:[email protected]:80
[[email protected] ~]#

You can see we have successfully set proxy with domain name username and password in above screen shot.

Special character handling in proxy setting

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

# export http_proxy=http://DOMAIN\\USERNAME:[email protected]:PORT/

If we have a @ symbol in our username and password then we need to add a backslash (\) before the @ you can see example below:-

# export http_proxy=http://DOMAIN\\USERN\@ME:[email protected]:PORT
[roo[email protected] ~]# export http_proxy=http://test\\urclouds\@ME:[email protected]:80
[[email protected] ~]# echo $http_proxy
http://test\[email protected]:[email protected]:80
[[email protected] ~]#


# export http_proxy=http://DOMAIN\\USERNAME:P\@[email protected]:PORT
[[email protected] ~]# export http_proxy=http://test\\urclouds:abc\@[email protected]:80
[[email protected] ~]# echo $http_proxy
http://test\urclouds:[email protected]@
[[email protected] ~]#

You can see in above screen shot we have successfully set password or username where we have a @ symbol.

Permanently Proxy configuration in CentOS 7  and RHEL 7 (for processes without shell)

We can define the environment variables in /etc/environment file if we want to add a permanent proxy in the CentOS 7 and  RHEL 7. Like below:-

# echo "http_proxy=" > /etc/environment
[[email protected] ~]# echo "http_proxy=" > /etc/environment
[[email protected] ~]# cat /etc/environment
[[email protected] ~]#

You can see we have successfully added proxy in /etc/environment file in above screen shot.

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/ file:

# echo "export http_proxy=" > /etc/profile.d/
[[email protected] ~]# echo "export http_proxy=" > /etc/profile.d/
[[email protected] ~]# ls -l /etc/profile.d/
-rw-r--r-- 1 root root 43 Jan 12 18:00 /etc/profile.d/
[[email protected] ~]# cat /etc/profile.d/
export http_proxy=
[[email protected] ~]#

Proxy setting for other programs

If we want to use yum program to install package through internet repository or any local repository then we need to set proxy into  /etc/yum.conf. like below:-

[[email protected] ~]# cat /etc/yum.conf
#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

[[email protected] ~]#

Proxy setting in Mozilla browser in CentOS 7 and RHEL 7

First of all click on Applications then click on Firefox web browser. Then your Firefox we browser will be open. Now you have to click open menu on right side top corner. Then you have to select preferences. After that we need to click on Advance then we have to select network and click on setting. After that we can get a windows where we can set proxy. Like below:-

That’s all we have configure proxy in CentOS 7 and RHEL 7 in this tutorial.

How to configure VLAN network in RHEL 7 and CentOS 7


  1. Johnie Ferlenda said:

    Hi guys! Just wanted to drop you a line to say that I really enjoyed reading your guest article on Peaches and Screams UK site! Great perspective. Have an awesome day!

    January 31, 2019
  2. no credit check loans said:

    Hello, I followed a link to your blog and I enjoyed this post particularly. . How might I find out more?

    February 10, 2019
  3. Alfonzo Balasubramani said:

    Wow, marvelous blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your web site is magnificent, let alone the content!

    February 21, 2019
  4. Lauren Sleva said:

    Very nice post. I just stumbled upon your weblog and wanted to mention that I have reallyloved surfing around your blog posts. In any case I’ll be subscribingfor your rss feed and I am hoping you write oncemore soon!

    February 24, 2019
  5. Irwin Petties said:

    I was suggested this blog by my cousin. I’m not sure whether this post is written by him as nobody else know such detailed about my trouble. You are incredible! Thanks!

    February 25, 2019
  6. Julian Nichol said:

    Superb blog! Do you have any helpful hints for aspiring writers? I’m hoping to start my own blog soon but I’m a little lost on everything. Would you advise starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m completely confused .. Any ideas? Appreciate it!

    February 28, 2019
  7. Rosette Prall said:

    Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a little bit, but other than that, this is excellent blog. An excellent read. I’ll certainly be back.

    March 2, 2019
  8. Elvin Heimlich said:

    You have observed very interesting details ! ps nice site. “Become addicted to constant and never-ending self improvement.” by Anthony D’Angelo.

    March 4, 2019
  9. Regan Licata said:

    I take pleasure in, result in I discovered just what I used to be having a look for. You have ended my 4 day lengthy hunt! God Bless you man. Have a great day. Bye

    March 14, 2019
  10. Roosevelt Wale said:

    This is very interesting, You are a very skilled blogger. I have joined your rss feed and look forward to seeking more of your wonderful post. Also, I’ve shared your web site in my social networks!

    March 20, 2019
  11. Caroyln Hosea said:

    Pretty! This was an incredibly wonderful article. Thanks for providing this information.

    March 22, 2019
  12. Walter Shepardson said:

    I loved your blog post.Really looking forward to read more.

    March 24, 2019
  13. Neida Lynchj said:

    Excellent blog! Do you have any tips for aspiring writers? I’m hoping to start my own site soon but I’m a little lost on everything. Would you suggest starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m totally overwhelmed .. Any suggestions? Kudos!

    March 26, 2019
  14. Marylou Delp said:

    As I site possessor I believe the content material here is rattling great , appreciate it for your hard work. You should keep it up forever! Good Luck.

    March 31, 2019
  15. gamefly free trial said:

    Hi, I do think this is a great site. I stumbledupon it 😉 I’m going to
    come back once again since I saved as a favorite it. Money and freedom is the greatest
    way to change, may you be rich and continue to help other people.

    May 23, 2019
  16. how to get help in windows 10 said:

    Hello I am so excited I found your website, I really found you
    by accident, while I was browsing on Google for something else, Anyhow I am here now and would just like to say thanks for
    a fantastic post and a all round exciting blog (I
    also love the theme/design), I don’t have time to go through it
    all at the moment but I have bookmarked it and also included your RSS feeds,
    so when I have time I will be back to read
    a great deal more, Please do keep up the fantastic jo.

    May 26, 2019
  17. said:

    hey there and thank you for your info – I have definitely picked up anything new from right here.
    I did however expertise some technical points using this web site, as I experienced to
    reload the website many times previous to I could get it to load properly.
    I had been wondering if your hosting is OK? Not
    that I’m complaining, but slow loading instances times will often affect your placement in google
    and can damage your quality score if advertising and marketing with Adwords.

    Well I’m adding this RSS to my e-mail and can look out for a lot more of your respective
    fascinating content. Make sure you update this again very soon.

    June 11, 2019
  18. gelnagels said:

    Hello! This is my 1st comment here so I just wanted to give a quick shout
    out and say I really enjoy reading through your articles.
    Can you recommend any other blogs/websites/forums that go over the same topics?
    Appreciate it!

    June 12, 2019
  19. Tangela said:

    Hello, I enjoy reading all of your article post.

    I wanted to write a little comment to support you.

    June 12, 2019
  20. Kathie said:

    I read this paragraph completely regarding the resemblance of
    newest and earlier technologies, it’s remarkable article.

    June 14, 2019
  21. Grizzly vildlakseolie said:

    Major thanks for the blog.Really thank you! Really Great.

    June 26, 2019
  22. surfers said:

    Respect to website author , some wonderful entropy.

    June 28, 2019
  23. Dane said:

    Hello, Neat post. There is a problem with your website in internet
    explorer, may check this? IE still is the market leader and a huge part of folks will leave
    out your great writing because of this problem.

    July 16, 2019
  24. Alysa said:

    hi!,I love your writing so much! percentage we be in contact more about your article on AOL?

    I require an expert on this house to solve my problem.
    May be that’s you! Looking ahead to look you.

    August 29, 2019
  25. Royce Wittich said:

    I blog often and I seriously appreciate your information. This article has truly peaked my interest. I am going to take a note of your website and keep checking for new information about once per week. I opted in for your Feed too.

    September 8, 2019
  26. Shannan said:

    Hello friends, nice paragraph and pleasant arguments commented here,
    I am really enjoying by these.

    February 16, 2020

Leave a Reply

Your email address will not be published. Required fields are marked *