Howto setup a local yum proxy for your LAN using http-replicator on SME Server 7.0
So you want to setup a local proxy to apt & yum updates for your LAN. This will help save you some bandwidth if you have a a few PC’s on the LAN that use yum to install & update any software.
From the homepage, http://dag.wieers.com/rpm/packages/http-replicator/, we can see the following:
HTTP Replicator is a general purpose, replicating HTTP proxy server.
All downloads through the proxy are checked against a private cache, which is an exact copy of the remote file structure. If the requested file is in the cache, replicator sends it out at LAN speeds. If not in the cache, it will simultaneously download the file and stream it to multiple clients.
No matter how many machines request the same file, only one copy comes down the Internet pipe. This is very useful for maintaining a cache of Linux packages.
Since I use SME Server, I’ll be using the Dag Wieers Repository to install http-replicator.
First we need to install the DAG Wieers Repository on SME, as follows:
[php]
wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
rpm –import RPM-GPG-KEY.dag.txt
/sbin/e-smith/db yum_repositories set dag repository \\
Name ‘Dag – EL4′ \\
BaseURL ‘http://apt.sw.be/redhat/el4/en/$basearch/dag’ \\
EnableGroups no \\
GPGCheck yes \\
GPGKey http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt \\
Visible no \\
Exclude freetype,htop,iptraf,rsync,syslinux \\
status disabled
expand-template /etc/yum.conf
[/php]
Once, Dag Wieers’s Repository is installed, we can install http-replicator, as follows:
[shell]
/usr/bin/yum –enablerepo=dag install http-replicator
[/shell]
NOTE: We need to use the –enablerepro=dag option to use the DAG Wieers Repository.
Now that http-replicator is installed, we need to configure it, and then configure yum to make use of it.
First, we edit the config file, which is /etc/sysconfig/http-replicator, and configure http-proxy to allow our IP subnet to access it.
[shell]
### Port on which the HTTP Replicator proxy should listen on.
PORT=”8080″
### Whitespace-separated list of IP addresses of clients or client networks
### that are allowed to connect to the proxy.
ALLOW_IP=”127.0.0.1 192.168.10.*”
[/shell]
Since we’re caching all our downloaded software, it may be useful to back it up as well. So, I’m going to move the cache forlder to one of my iBays, which will then automatically get backed up every evening with the system backup.
This is also in the /etc/sysconfig/http-replicator:
[shell]
### User to use to run http-replicator
USER=”nobody”
### Cachedir location
CACHE_DIR=”/home/e-smith/files/ibays/software/files/http-replicator_cache/”
[/shell]
NOTE:
If you change the cache directory, you need to change the new directory’s ownership to guest:
[shell]
chown guest /home/e-smith/files/ibays/software/files/http-replicator_cache/
[/shell]
Next, we need to configure SME to use itself as a proxy, so to say.
In /etc/profile.d, create the following two files:
[shell]
[root@intranet ~]# cat /etc/profile.d/proxy.*
# proxy.csh
setenv http_proxy=http://192.168.10.5:8080
setenv ftp_proxy=http://192.168.10.5:8080
setenv no_proxy=http://192.168.10.5:8080
setenv HTTP_proxy=http://192.168.10.5:8080
setenv FTP_proxy=http://192.168.10.5:8080
# proxy.sh
export http_proxy=http://192.168.10.5:8080
export ftp_proxy=http://192.168.10.5:8080
export no_proxy=http://192.168.10.5:8080
export HTTP_proxy=http://192.168.10.5:8080
export FTP_proxy=http://192.168.10.5:8080
[/shell]
Now, logout, and log back in to make the new shell enviroment files to be read. To see if it has worked, do the following:
[shell]
[root@intranet ~]# env | grep proxy
HTTP_proxy=http://192.168.10.5:8080
http_proxy=http://192.168.10.5:8080
ftp_proxy=http://192.168.10.5:8080
no_proxy=http://192.168.10.5:8080
FTP_proxy=http://192.168.10.5:8080
[/shell]
The last thing we need todo, is to make http-replicator auto-startup when SME Server starts. This can be doing by adding the following command to /etc/rc.local
[shell]
/etc/init.d/http-replicator start
[/shell]
Great! Now we have http-proxy setup to cashe all yum updates & installations
Useful links:
http://dag.wieers.com/rpm/FAQ.php#B4
http://gertjan.freezope.org/replicator/
