我的系统:
uname -a
FreeBSD server.local.jmorenov.com.co 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec 4 09:23:10 UTC 2012 [email protected]:/usr/obj/usr/src/sys/GENERIC amd64
pkg info | grep squid
squid-3.2.7 HTTP Caching Proxy
我在 squid.conf 中有这样的配置:
http_port 3128 accel vhost allow-direct # OK
http_port 3129 intercept # Does not work
icp_port 0
当我尝试时:
http_port 3129 intercept
通过 ipnat.rules 上的 switch 行。在访问日志中出现:
2013/01/09 00:46:03 kid1| IPF (IPFilter) NAT open failed: (13) Permission denied
2013/01/09 00:46:03 kid1| BUG #3329: Orphan Comm::Connection: local=127.0.0.1:3129 remote=192.168.1.129:51595 FD 24 flags=33
2013/01/09 00:46:03 kid1| NOTE: 1 Orphans since last started.
/var/log/squid/cache.log
2013/02/08 09:02:33 kid1| Squid plugin modules loaded: 0
2013/02/08 09:02:33 kid1| Accepting reverse-proxy HTTP Socket connections at local=127.0.0.1:3128 remote=[::] FD 33 flags=9
2013/02/08 09:02:33 kid1| Accepting NAT intercepted HTTP Socket connections at local=127.0.0.1:3129 remote=[::] FD 34 flags=41
我的/etc/ipnat.rules:
root@server:/root # cat /etc/ipnat.rules
# em0 = External NIC
# bge0 = Internal NIC
map em0 0/0 -> 0/32 proxy port ftp ftp/tcp
map em0 0/0 -> 0/32 portmap tcp/udp auto
map em0 0/0 -> 0/32
# Redirect direct web traffic to local web server.
rdr em0 192.168.0.3/32 port 80 -> 127.0.0.1 port 80 tcp
rdr bge0 192.168.1.3/32 port 80 -> 127.0.0.1 port 80 tcp
# Redirect everything else to squid on port 3128 or 3129 intercept
rdr em0 0.0.0.0/0 port 80 -> 127.0.0.1 port 3128 tcp
rdr bge0 0.0.0.0/0 port 80 -> 127.0.0.1 port 3128 tcp
#rdr em0 0.0.0.0/0 port 80 -> 127.0.0.1 port 3129 tcp
#rdr bge0 0.0.0.0/0 port 80 -> 127.0.0.1 port 3129 tcp
使用 3128 可以,但是使用 3129 时,在 ipnat.rules 中切换时不起作用。
答案1
你确实想在 Freebsd 下使用 pf 和 Intercept -http://wiki.squid-cache.org/ConfigExamples/Intercept/FreeBsdPf。
由于需要使用 ipfw,我们已成功使 tproxy 正常工作,但它需要进行内核更改(http://wiki.squid-cache.org/Features/Tproxy4)。