Squid在创建代理服务器时拒绝所有网站



所以我正试图创建一个代理服务器供我的爬网程序使用,我不确定为什么我自己都拒绝了。当我在浏览器中访问任何网站时,在我安装了Squid和所有东西的计算机上,它会给我以下错误消息:

ERROR
The requested URL could not be retrieved
While trying to retrieve the URL: http://www.whatismyipaddress.com/
The following error was encountered:
Access Denied.
Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect.
Your cache administrator is webmaster. 
Generated Sun, 08 Nov 2015 04:03:13 GMT by WIN-AIUOBK0JHPA (squid/2.7.STABLE8)

我已经在"Internet选项"中编辑了我的LAN设置,以允许在正确的IP地址(运行ipconfig时为IPv4)上使用代理服务器,为其提供了正确的端口以打开,我还在Windows防火墙中打开了该端口。

以下是我的squid.conf文件的片段:

acl SSL_ports port 443
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 CONNECT method CONNECT
acl localhost src 192.168.1.0/255.255.255.255 
http_access allow localhost
(skip through some commented out segments....)
http_access allow manager localhost
http_access allow localnet

正如你所知,我去掉了很多不必要的评论部分。往下看,我有我的…

http_port ####

线

我不知道为什么我被挡在门外。我会不断更新,所以如果你需要更多信息或有任何问题,请告诉我。非常感谢!!

您的配置应该有点像

http_access allow localhost 
http_access allow localnet 
# And finally deny all other access to this proxy 
http_access deny all

并从配置中删除以下行

acl localhost src 192.168.1.0/255.255.255.255 

localhost不需要指定为ACL,它只用于访问localhost页面。您已经混淆了localhost和localnet,如下面所示修改该行

acl localnet src 192.168.1.0/255.255.255.255 

您的lan客户端的本地ip应该属于上述src范围,或者根据需要修改该范围。来自其他ip的所有其他请求都将被拒绝

我刚刚去掉了所有默认配置,并使用了以下内容:

# cat /etc/squid/squid.conf
http_port 3128
acl vpc_no_internet src 10.130.0.0/255.255.0.0
http_access allow vpc_no_internet
coredump_dir /var/spool/squid
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|?) 0     0%      0
refresh_pattern (Release|Packages(.gz)*)$      0       20%     2880
refresh_pattern .               0       20%     4320

注意:上面的配置只允许访问指定的子网。

我遇到了类似的情况,解决方案是使用以下命令:

取消设置https_proxy

取消设置http_proxy

取消设置ftp_proxy

我把这些放在一个脚本中,每次登录到服务器时都会运行。这可能不是适合你的正确解决方案,但它在我的情况下有效,因为我没有使用代理,而是通过vpn连接。

我发布这篇文章的唯一原因是我没有在其他地方看到这个答案。和往常一样,YMMV。

最新更新