我遵循以下有关Squid Cache: Version 3.5.20
https://wiki.squid-cache.org/ConfigExamples/Intercept/LinuxDnat
然而,当我使用curl获取网站时,我得到503并且squid标头是错误111:
# curl -I neverssl.com
HTTP/1.1 503 Service Unavailable
Server: squid/3.5.20
Mime-Version: 1.0
Date: Mon, 11 Jun 2018 15:05:55 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 3559
X-Squid-Error: ERR_CONNECT_FAIL 111
Vary: Accept-Language
Content-Language: en
X-Cache: MISS from my-squid.dev.local
X-Cache-Lookup: MISS from my-squid.dev.local:3128
Via: 1.1 my-squid.dev.local (squid/3.5.20)
Connection: keep-alive
我在客户端上设置了hosts文件,以便neverssl.com
指向s 192.168.90.31
这是我的squid配置文件:
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 localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
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
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access allow localnet
http_access allow localhost
http_port 3128
http_port 3127 intercept
http_port 3126 intercept
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 . 0 20% 4320
如果我使用代理环境标签,代理在端口3128上正常工作,但我想让透明代理工作。
这是我设置的iptables配置:
SQUIDIP=192.168.90.31
SQUIDPORT=3126
iptables -t nat -A PREROUTING -s $SQUIDIP -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port $SQUIDPORT
iptables -t nat -A POSTROUTING -j MASQUERADE
iptables -t mangle -A PREROUTING -p tcp --dport $SQUIDPORT -j DROP
sysctl设置为:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.accept_source_route = 0
提前致谢。