树莓派配置Squid作为网络代理服务器

 

Next, we want to update our Raspberry Pi with the latest patches.  Open a new shell window

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Hit Y if prompted.

Now we have a fully patched and up-to-date version of rasparian; its time to install Squid.

 

Install Squid:

Enter the following in the shell

sudo apt-get install squid3

 

Configuring Squid:

Backup the Squid config file:

注意:可能安装后无squid3文件夹,只有squid文件夹,则以下所有涉及squid3的都改为squid。

sudo cp /etc/squid3/squid.conf /etc/squid3/squidoriginal.conf.bak
sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.bak

 

Edit the config file:

sudo nano /etc/squid3/squid.conf

use Ctrl + W to find each section:

http_access allow localnet = remove the #

squid conf 1.png

http_access deny all 改为 http_access allow all
Remove #   from: acl localnet src + add ip range/cidr 192.168.5.0/24

Make sure the ip range/cidr matches your networks range

squid conf 2.png

Find: #dns_v4_first off remove # and change off to on.

squid conf 3.png

Cache_mem 256 MB

squid conf 4.png

Maximum_object_size 4096 MB

squid conf 5.png

Maximum_object_size_in_memory 8192 KB


#Cache_dir ufs /var/spool/squid3 = 8192 16 256
此设置如硬盘空间太小,可关闭,仅将树莓派作为网络代理时,无需开启。


Backup the squid config file and restart the Squid service:

sudo service squid3 restart

squid conf 8.png

 

Make managing Squid easier with Webmin:

First, install webmins prereqs; open a shell and enter:

sudo apt-get -f install
sudo apt-get -y install apache2 apache2-suexec-custom libnet-ssleay-perl libauthen-pam-perl libio-pty-perl apt-show-versions samba bind9 webalizer locate mysql-server
sudo apt-get install squid-cgi

Enter a secure password for MySQL when prompted.:

mysql1.png

From the shell enter these commands in turn:

sudo wget http://www.webmin.com/download/deb/webmin-current.deb
sudo dpkg -i webmin-current.deb

 

Once Webmin has been installed; open a browser on your pc https://192.168.5.240:10000

Login using the raspberry pi login (default is pi and raspberry).

webmin1.png

In webmin; you’ll be able to adjust Squid settings through webmin.  Look under servers; Squid proxy server.

webmin2.png

 

Configuring the client:

Set windows browser proxy: Enter the ip address of the Raspberry Pi (192.168.5.250) and port 3128. Restart browser.

client proxy 1.png

Clear your browser cache and restart the browser.  You should now be using the Squid Proxy server on your Raspberry Pi.

 

Check the cache log:

To check the squid cache logs, open a new shell window and enter:

sudo tail -f /var/log/squid3/access.log

Hits are items being pulled from the Squid Cache rather than the internet.

hit log.png

Summary:

If your unlucky enough to have a slow or laggy internet connection,  one possible solution for you is to build and test a Squid proxy server.  However, bear in mind, your mileage may vary as not all objects are cacheable, and certainly any improvement is less noticiable on fast internet connections such as BT infinity.

I performed some “not very scientific” tests using OpenOffice.org.  I found that the download speed of the OpenOffice installer on the first try was 3.9mbs, jumping to 7.9Mb/s after caching once, then maxing out at 9.8Mb/s on the second and subsequent runs (likely a limitation of the Raspberry Pi’s network card – which is limited to 100mbs).


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值