配置squid做二级代理,支持访问http和https

来源:互联网 发布:sql培训课程 编辑:程序博客网 时间:2024/05/29 07:01

公司A电脑可以通过代理上网,B电脑无法连接代理服务器,但可以连接到A,因此考虑使用squid在A电脑上搭建二级代理,以达到B电脑可以访问internet的目的。

以下引自squid-cache wiki:http://wiki.squid-cache.org/Features/CacheHierarchy?highlight=%28%5CbCategoryFeature%5Cb%29%7C%28faqlisted.yes%29

How do I configure Squid forward all requests to another proxy?


First, you need to give Squid a parent cache with the cache_peer directive. Second, you need to tell Squid it can not connect directly to origin servers with never_direct. This is done with these configuration file lines:

cache_peer parentcache.foo.com parent 3128 0 no-query default
never_direct allow all

比如,原代理服务器地址是192.168.1.5,端口是8080,那么应该在squid的配置文件squid.conf中增加以下内容:

cache_peer 192.168.1.5 parent 8080 0 default
never_direct allow all

如果原代理服务器需要用户名密码,那么配置的内容应为:

cache_peer 192.168.1.5 parent 8080 0 login=account:passwd default
never_direct allow all

其中accountpasswd需要修改成访问原代理服务器的用户名和密码。

如果没有添加配置”never_direct allow all“,那么访问 https网页时,squid服务器就会不经过原代理服务器,直接去访问https网页,由于squid服务器是需要代理服务器才能上网的,因此就会出现无法建立连接的错误。

原创粉丝点击