个人工具

“UbuntuHelp:HttpReplicator”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第2行: 第2行:
 
{{Languages|UbuntuHelp:HttpReplicator}}
 
{{Languages|UbuntuHelp:HttpReplicator}}
 
== Guide for setting up http-replicator, a download cache (proxy) for Ubuntu packages ==
 
== Guide for setting up http-replicator, a download cache (proxy) for Ubuntu packages ==
 
 
http-replicator is a powerful Python-based proxy or download cache capable of caching any traffic over http. It's best when used for a network of Ubuntu machines, saving bandwidth and increasing the speed with which updates are obtained by all machines.  
 
http-replicator is a powerful Python-based proxy or download cache capable of caching any traffic over http. It's best when used for a network of Ubuntu machines, saving bandwidth and increasing the speed with which updates are obtained by all machines.  
 
 
'''NOTE:'''
 
'''NOTE:'''
 
The deb available from the freshmeat page for this package is older then the one here, so please use the one given below.
 
The deb available from the freshmeat page for this package is older then the one here, so please use the one given below.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
wget http://gertjan.freezope.org/replicator/http-replicator_3.0_i386.deb
 
wget http://gertjan.freezope.org/replicator/http-replicator_3.0_i386.deb
 
sudo dpkg -i http-replicator_3.0_i386.deb
 
sudo dpkg -i http-replicator_3.0_i386.deb
 
</nowiki></pre>
 
</nowiki></pre>
 
 
If, when you download and install this, dpkg attempts to start http-replicator and then complains of not being able to find the command source, it's because /bin/sh in Edgy Eft and later releases does not default to bash (As far as I can see). You will need to edit /etc/init.d/http-replicator by doing  
 
If, when you download and install this, dpkg attempts to start http-replicator and then complains of not being able to find the command source, it's because /bin/sh in Edgy Eft and later releases does not default to bash (As far as I can see). You will need to edit /etc/init.d/http-replicator by doing  
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo sensible-editor /etc/init.d/http-replicator
 
sudo sensible-editor /etc/init.d/http-replicator
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Change  
 
Change  
 
<pre><nowiki>
 
<pre><nowiki>
第27行: 第21行:
 
#! /bin/bash
 
#! /bin/bash
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Unfortunately, this .deb doesn't create and do everything it needs to by default, so we need to create the cache for the files and give ownership of the cache to the http-replicator daemon.
 
Unfortunately, this .deb doesn't create and do everything it needs to by default, so we need to create the cache for the files and give ownership of the cache to the http-replicator daemon.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo mkdir /var/cache/http-replicator
 
sudo mkdir /var/cache/http-replicator
 
sudo chown proxy.root /var/cache/http-replicator
 
sudo chown proxy.root /var/cache/http-replicator
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Now, to configure the proxy, open up the config file with
 
Now, to configure the proxy, open up the config file with
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo sensible-editor /etc/default/http-replicator
 
sudo sensible-editor /etc/default/http-replicator
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Look at the line
 
Look at the line
 
<pre><nowiki>
 
<pre><nowiki>
 
DAEMON_OPTS="$GENERAL_OPTS --port 8080 --log /var/log/http-replicator.log --user proxy"
 
DAEMON_OPTS="$GENERAL_OPTS --port 8080 --log /var/log/http-replicator.log --user proxy"
 
</nowiki></pre>
 
</nowiki></pre>
 
 
And change it to
 
And change it to
 
<pre><nowiki>
 
<pre><nowiki>
 
DAEMON_OPTS="$GENERAL_OPTS --port 8080 --log /var/log/http-replicator.log --user proxy --ip=192.168.0.*"
 
DAEMON_OPTS="$GENERAL_OPTS --port 8080 --log /var/log/http-replicator.log --user proxy --ip=192.168.0.*"
 
</nowiki></pre>
 
</nowiki></pre>
 
 
`--ip=192.168.0.*`is whatever network address space your using.
 
`--ip=192.168.0.*`is whatever network address space your using.
 
 
Its probably worth noting that ? and * are wildcards supported by http-replicator. You can make it accept connections from one host (or multiple hosts if you use --ip= more then once) or an entire subnet (as above).
 
Its probably worth noting that ? and * are wildcards supported by http-replicator. You can make it accept connections from one host (or multiple hosts if you use --ip= more then once) or an entire subnet (as above).
 
 
The other change you might like to do is change the port to 80. What this will do is make http-replicator cache all web trafic, without requiring you to reconfigure any client settings at all.
 
The other change you might like to do is change the port to 80. What this will do is make http-replicator cache all web trafic, without requiring you to reconfigure any client settings at all.
 
Your resultant line will look something like:
 
Your resultant line will look something like:
第60行: 第45行:
 
DAEMON_OPTS="$GENERAL_OPTS --port 80 --log /var/log/http-replicator.log --user proxy --ip=192.168.0.*"
 
DAEMON_OPTS="$GENERAL_OPTS --port 80 --log /var/log/http-replicator.log --user proxy --ip=192.168.0.*"
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Then remove the line that says
 
Then remove the line that says
 
<pre><nowiki>
 
<pre><nowiki>
第66行: 第50行:
 
</nowiki></pre>
 
</nowiki></pre>
 
Save the file and exit.
 
Save the file and exit.
 
 
Restart the daemon (or start for the first time)
 
Restart the daemon (or start for the first time)
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo /etc/init.d/http-replicator restart
 
sudo /etc/init.d/http-replicator restart
 
</nowiki></pre>
 
</nowiki></pre>
 
 
And you're finished with the proxy!
 
And you're finished with the proxy!
 
 
Now, all you have to do is get the clients ready. Note that if you changed the port http-replicator runs on to port 80, the following is unneeded. (The example given below is for proxying packages downloaded by APT).
 
Now, all you have to do is get the clients ready. Note that if you changed the port http-replicator runs on to port 80, the following is unneeded. (The example given below is for proxying packages downloaded by APT).
 
 
On the local computer you want to use http-replicator with, add this line to /etc/apt/apt.conf
 
On the local computer you want to use http-replicator with, add this line to /etc/apt/apt.conf
 
 
<pre><nowiki>
 
<pre><nowiki>
 
Acquire::http::Proxy "http://192.168.0.1:8080";
 
Acquire::http::Proxy "http://192.168.0.1:8080";
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Replace 192.168.0.1 with the IP of the server http-replicator is running on.
 
Replace 192.168.0.1 with the IP of the server http-replicator is running on.
 
 
 
==== More info: ====
 
==== More info: ====
 
<br>man 1 http-replicator
 
<br>man 1 http-replicator
 
<br>man 1 http-replicator_maintenance
 
<br>man 1 http-replicator_maintenance
 
<br>http://gertjan.freezope.org/replicator/
 
<br>http://gertjan.freezope.org/replicator/
 
 
 
==== For the record, the following files are installed by the .deb ====
 
==== For the record, the following files are installed by the .deb ====
 
<pre><nowiki>
 
<pre><nowiki>

2007年11月30日 (五) 17:46的版本

Guide for setting up http-replicator, a download cache (proxy) for Ubuntu packages

http-replicator is a powerful Python-based proxy or download cache capable of caching any traffic over http. It's best when used for a network of Ubuntu machines, saving bandwidth and increasing the speed with which updates are obtained by all machines. NOTE: The deb available from the freshmeat page for this package is older then the one here, so please use the one given below.

wget http://gertjan.freezope.org/replicator/http-replicator_3.0_i386.deb
sudo dpkg -i http-replicator_3.0_i386.deb

If, when you download and install this, dpkg attempts to start http-replicator and then complains of not being able to find the command source, it's because /bin/sh in Edgy Eft and later releases does not default to bash (As far as I can see). You will need to edit /etc/init.d/http-replicator by doing

sudo sensible-editor /etc/init.d/http-replicator

Change

#! /bin/sh

in the first line to

#! /bin/bash

Unfortunately, this .deb doesn't create and do everything it needs to by default, so we need to create the cache for the files and give ownership of the cache to the http-replicator daemon.

sudo mkdir /var/cache/http-replicator
sudo chown proxy.root /var/cache/http-replicator

Now, to configure the proxy, open up the config file with

sudo sensible-editor /etc/default/http-replicator

Look at the line

DAEMON_OPTS="$GENERAL_OPTS --port 8080 --log /var/log/http-replicator.log --user proxy"

And change it to

DAEMON_OPTS="$GENERAL_OPTS --port 8080 --log /var/log/http-replicator.log --user proxy --ip=192.168.0.*"

`--ip=192.168.0.*`is whatever network address space your using. Its probably worth noting that ? and * are wildcards supported by http-replicator. You can make it accept connections from one host (or multiple hosts if you use --ip= more then once) or an entire subnet (as above). The other change you might like to do is change the port to 80. What this will do is make http-replicator cache all web trafic, without requiring you to reconfigure any client settings at all. Your resultant line will look something like:

DAEMON_OPTS="$GENERAL_OPTS --port 80 --log /var/log/http-replicator.log --user proxy --ip=192.168.0.*"

Then remove the line that says

exit 0 # REMOVE THIS LINE TO ACTIVATE THE PROXY SERVER

Save the file and exit. Restart the daemon (or start for the first time)

sudo /etc/init.d/http-replicator restart

And you're finished with the proxy! Now, all you have to do is get the clients ready. Note that if you changed the port http-replicator runs on to port 80, the following is unneeded. (The example given below is for proxying packages downloaded by APT). On the local computer you want to use http-replicator with, add this line to /etc/apt/apt.conf

Acquire::http::Proxy "http://192.168.0.1:8080";

Replace 192.168.0.1 with the IP of the server http-replicator is running on.

More info:


man 1 http-replicator
man 1 http-replicator_maintenance
http://gertjan.freezope.org/replicator/

For the record, the following files are installed by the .deb

./
usr/
usr/share/
usr/share/doc/
usr/share/doc/http-replicator/
usr/share/doc/http-replicator/README.gz
usr/share/doc/http-replicator/copyright
usr/share/doc/http-replicator/examples/
usr/share/doc/http-replicator/examples/apt.conf
usr/share/doc/http-replicator/changelog.gz
usr/share/man/
usr/share/man/man1/
usr/share/man/man1/http-replicator.1.gz
usr/share/man/man1/http-replicator_maintenance.1.gz
usr/bin/
usr/bin/http-replicator
usr/bin/http-replicator_maintenance
etc/
etc/logrotate.d/
etc/logrotate.d/http-replicator
etc/default/
etc/default/http-replicator
etc/init.d/
etc/init.d/http-replicator
etc/cron.weekly/
etc/cron.weekly/http-replicator