Tuesday, September 30, 2014

configure http proxy on CentOS

1. You can configure persistent proxy environment variable in /etc/profile.d so it will be set every time you login :

[root@mangkuk ~]# cat /etc/profile.d/proxy.sh
http_proxy=http://myproxy:8080
https_proxy=$http_proxy
ftp_proxy=$http_proxy
export http_proxy https_proxy ftp_proxy


2. The proxy for yum package manager need to be configured separately in /etc/yum.conf. The proxy line need to be added under [main] section:

[root@mangkuk ~]# cat /etc/yum.conf
[main]
proxy=http://myproxy:8080
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=16&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
[root@mangkuk ~]#


1 comment: