Categories
技术讨论

试用基于Xen的VPS(2):配置squid服务器

前面总结了 基于Xen的VPS的web服务器的配置:ubuntu+nginx+php,下面记录下squid服务器的配置。

安装很简单:apt-get install squid

配置中的重点是打开用户验证。

通过htpasswd建立用户名密码文件,然后在squid的配置文件中设置。

http_port 3128
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid.password
auth_param basic children 5
auth_param basic realm Hamo’s Private Proxy
auth_param basic credentialsttl 4 hours

acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl localnet src 10.0.0.0/8    # RFC1918 possible internal network
acl localnet src 172.16.0.0/12    # RFC1918 possible internal network
acl localnet src 192.168.0.0/16    # RFC1918 possible internal network

acl SSL_ports port 443        # https
acl SSL_ports port 563        # snews
acl SSL_ports port 873        # rsync
acl Safe_ports port 80        # http
acl Safe_ports port 21        # ftp
acl Safe_ports port 443        # https
acl Safe_ports port 70        # gopher
acl Safe_ports port 210        # wais
acl Safe_ports port 1025-65535    # unregistered ports
acl Safe_ports port 280        # http-mgmt
acl Safe_ports port 488        # gss-http
acl Safe_ports port 591        # filemaker
acl Safe_ports port 777        # multiling http
acl Safe_ports port 631        # cups
acl Safe_ports port 873        # rsync
acl Safe_ports port 901        # SWAT
acl purge method PURGE
acl CONNECT method CONNECT

acl normal proxy_auth REQUIRED

http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny to_localhost
http_access allow localhost
http_access allow normal
http_access deny all

然后重启squid即可。

14 replies on “试用基于Xen的VPS(2):配置squid服务器”

hi.我运行/etc/init.d/squid restart后出现如下错误,提示这行代码:acl normal proxy_auth REQUIRED无效,因为no authentication schemes are fully configured(没有完整配置认证计划),那么如何配置认证计划呢?如何生成squid.passwod(/etc/squid/squid.password)文件?

# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2010/03/14 16:47:11| Invalid Proxy Auth ACL ‘a cl normal proxy_auth REQUIRED’ because no authentication schemes are fully confi gured.
FATAL: Bungled squid.conf line 630: acl normal proxy_auth REQUIRED
Squid Cache (Version 2.7.STABLE3): Terminated abnormally.
failed!

@ym
你没有设置认证的方式,比如没有生成密码文件或者路径不对,提示写得很清楚了

btw: vps上的话用3proxy更简单方便一些

我用了此文:http://www.x2009.cn/articles/apache-web-server-through-htaccess-and-htpasswd-to-set-a-password-to-the-web-folder-the-method.html来设置htpasswd,但是无效。我的vps装的webserver是lighttpd,不是apache,这种设置方法对lighttpd无效吗?

@ym 那篇文章只是示意,并没有可操作的步骤。按我这篇文章的话,你需要用htpasswd生成一个密码文件,和lighttpd无关。
不过还是建议你用3proxy来开代理http://www.satwe.com/archives/997.html,设置还简单。squid对vps来说太庞大了。

如何用htpasswd生成一个密码文件?详细写写吧,我是菜鸟。先把squid学会,再弄3proxy

我没有启用auth_param,用/etc/init.d/squid restart重启squid,结果正常。然后在浏览器中如何设置呢?是127.0.0.1:3128还是我的vps的ip:3128?我试过2种都不行,请赐教

哈哈,设置成功。自己用,不需要启用auth_param。ff浏览器中选择ssl proxy,后面填写我的vps的ip,端口3128.搞定。比你推荐的3proxy容易的多。博主何必这么保守呢。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.