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
[root@urclouds ~]# echo $http_proxy
[root@urclouds ~]#

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/
[root@urclouds ~]# export http_proxy=http://192.168.30.50:80
[root@urclouds ~]#
[root@urclouds ~]# echo $http_proxy
http://192.168.30.50:80
[root@urclouds ~]#

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

[root@urclouds ~]# unset http_proxy
[root@urclouds ~]# echo $http_proxy
[root@urclouds ~]#

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:PASSWORD@SERVER:PORT/
[root@urclouds ~]# export http_proxy=http://urclouds:abc123@192.168.30.50:80
[root@urclouds ~]# echo $http_proxy
http://urclouds:abc123@192.168.30.50:80
[root@urclouds ~]#

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:PASSWORD@SERVER:PORT/
[root@urclouds ~]# export http_proxy=http://test\\urclouds:abc123@192.168.30.50:80
[root@urclouds ~]# echo $http_proxy
http://test\urclouds:abc123@192.168.30.50:80
[root@urclouds ~]#

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:PASSWORD@SERVER: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:PASSWORD@SERVER:PORT
[root@urclouds ~]# export http_proxy=http://test\\urclouds\@ME:abc123@192.168.30.50:80
[root@urclouds ~]# echo $http_proxy
http://test\urclouds@ME:abc123@192.168.30.50:80
[root@urclouds ~]#

or

# export http_proxy=http://DOMAIN\\USERNAME:P\@SSWORD@SERVER:PORT
[root@urclouds ~]# export http_proxy=http://test\\urclouds:abc\@123@192.168.30.50:80
[root@urclouds ~]# echo $http_proxy
http://test\urclouds:abc@123@192.168.30.50:80
[root@urclouds ~]#

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=http://proxy.example.com:80/" > /etc/environment
[root@urclouds ~]# echo "http_proxy=http://192.168.30.50:80/" > /etc/environment
[root@urclouds ~]# cat /etc/environment
http_proxy=http://192.168.30.50:80/
[root@urclouds ~]#

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/http_proxy.sh file:

# echo "export http_proxy=http://proxy.example.com:80/" > /etc/profile.d/http_proxy.sh
[root@urclouds ~]# echo "export http_proxy=http://192.168.30.50:80/" > /etc/profile.d/http_proxy.sh
[root@urclouds ~]# ls -l /etc/profile.d/http_proxy.sh
-rw-r--r-- 1 root root 43 Jan 12 18:00 /etc/profile.d/http_proxy.sh
[root@urclouds ~]# cat /etc/profile.d/http_proxy.sh
export http_proxy=http://192.168.30.50:80/
[root@urclouds ~]#

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

[root@urclouds ~]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
#  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
proxy=http://192.168.30.50:80
proxy_username=urclouds
proxy_password=abc123

[root@urclouds ~]#

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.

This Post Has 54 Comments

  1. Johnie Ferlenda

    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!

  2. no credit check loans

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

  3. Alfonzo Balasubramani

    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!

  4. Lauren Sleva

    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!

  5. Irwin Petties

    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!

  6. Julian Nichol

    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!

  7. Rosette Prall

    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.

  8. Elvin Heimlich

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

  9. Regan Licata

    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

  10. Roosevelt Wale

    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!

  11. Caroyln Hosea

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

  12. Walter Shepardson

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

  13. Neida Lynchj

    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!

  14. Marylou Delp

    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.

  15. gamefly free trial

    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.

  16. how to get help in windows 10

    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.

  17. https://tinyurl.com

    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.

  18. gelnagels

    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!

  19. Tangela

    Hello, I enjoy reading all of your article post.

    I wanted to write a little comment to support you.

  20. Kathie

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

  21. Grizzly vildlakseolie

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

  22. ultimaapps.com/subway surfers

    Respect to website author , some wonderful entropy.

  23. Dane

    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.

  24. Alysa

    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.

  25. Royce Wittich

    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.

  26. Shannan

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

  27. Kurt Shuck

    “Great article and right to the point. I don’t know if this is in fact the best place to ask but do you folks have any thoughts on where to get some professional writers? Thank you ??”

  28. watch

    This page really has all the information I needed about this subject and didn’t know who to ask.

  29. CPA Firms Near Me

    This excellent website certainly has all the info I wanted about this subject and didn’t know who to ask.

  30. Elaine Dellarocco

    I just want to tell you that I am very new to weblog and absolutely liked your website. Very likely I’m planning to bookmark your blog post . You certainly come with amazing articles. Thanks for sharing your webpage.

  31. Proxy

    I got this site from my buddy who told me
    concerning this web page and at the moment this time I am visiting this web site and reading very informative articles or reviews at
    this place.

  32. Ben Keyte

    I don’t know where to start… I have been looking for this information for what seems like a lifetime. Many, many thanks for publishing it. I just want to give you a massive hug!

  33. Pansy

    What’s up everybody, here every one is sharing these kinds of experience,
    thus it’s nice to read this webpage, and I used to pay a visit this
    webpage all the time.

  34. Naomi

    Hello there, just became aware of your blog through Google, and found that it’s really informative.
    I’m going to watch out for brussels. I’ll be grateful if you continue this in future.
    Many people will be benefited from your writing. Cheers!

  35. Tammy

    Great blog here! Also your web site loads up very fast!
    What host are you using? Can I get your affiliate link to your host?
    I wish my site loaded up as fast as yours lol

  36. Ward

    I’m not sure where you’re getting your information,
    but good topic. I needs to spend some time learning more or understanding more.
    Thanks for magnificent info I was looking for this info for my mission.

  37. Kenneth

    Please let me know if you’re looking for a writer for your blog.
    You have some really great posts and I think I would be a good asset.

    If you ever want to take some of the load off, I’d really like to write some material
    for your blog in exchange for a link back to mine.

    Please shoot me an e-mail if interested. Regards!

  38. Verna

    I don’t even know how I ended up here, but I thought
    this post was great. I don’t know who you are but definitely you are going to
    a famous blogger if you are not already 😉 Cheers!

  39. Fernando

    You actually make it seem so easy with your presentation but I find this topic to
    be actually something that I think I would never understand.
    It seems too complicated and extremely broad for me. I am looking forward for your next post, I’ll try to get the
    hang of it!

  40. Moshe

    Its not my first time to pay a quick visit this web page, i
    am browsing this web page dailly and get fastidious data
    from here all the time.

  41. Hur man gör en ljudisoleringsstuga

    An intriguing discussion is worth comment. There’s no doubt that
    that you ought to write more about this topic, it might not be a taboo matter but usually folks don’t discuss such topics.
    To the next! Best wishes!!

  42. Man City

    Hmm it appears like your blog ate my fiorst comment (it was extremely long) so I gujess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog.
    I too am an aspiring blog writer but I’m still new to everything.
    Do youu have any suggestions for newbie blog writers?
    I’d genuinely appreciate it.

  43. Directory Proxy

    whoah this blog is wonderful i really like studying your articles.

    Stay up the great work! You recognize, many
    persons are searching around for this information, you can help them greatly.

  44. john week

    Thank you for your article post.Thanks Again. Really Great.

  45. slot online

    I am so grateful for your blog post.Much thanks again. Will read on…

  46. Carla

    An outstanding share! I’ve just forwarded this onto a
    co-worker who had been doing a little research on this.
    And he in fact bought me lunch because I discovered it for him…
    lol. So let me reword this…. Thank YOU for the meal!!
    But yeah, thanks for spending some time to discuss this topic here on your site.

  47. Medicīnas Konsultācijas

    Truly when someone doesn’t be aware of then its up to other viewers that they will
    assist, so here it happens.

  48. Selina

    I just could not go away your website before
    suggesting that I actually loved the usual info an individual
    supply to your visitors? Is gonna be back incessantly to check
    up on new posts

  49. DennisWhode

    Your own stuffs great. Always maintain it up!

  50. Cheryle

    I visited multiple websites however the audio feature for audio songs existing at this
    website is truly fabulous.

  51. product

    Please allow me to introduce myself I’m a man of wealth and taste I’ve been around for a long, long year Stole many a mans soul and faith And I was round when jesus christ Had his moment of doubt and pain.

  52. https://cuocsongquanhta.webflow.io/posts/thuoc-kich-duc-nam

    At this time I am going away to do my breakfast, once having my breakfast coming
    again to read other news.

  53. https://chuthapdohatinh.org.vn/upload/tailieu/noi-tie-1635826582t.htm

    Keep on working, great job!

Leave a Reply