我需要从默认的squid.conf中修改什么才能使其作为透明代理服务器工作?

时间:2013-04-25 10:02:58

标签: squid

我有一台带DD-WRT的路由器,从路由器转发似乎可以使用以下脚本:

#!/bin/sh
PROXY_IP=192.168.77.77
PROXY_PORT=3128
LAN_IP=`nvram get lan_ipaddr`
LAN_NET=$LAN_IP/`nvram get lan_netmask`

iptables -t nat -A PREROUTING -i br0 -s $LAN_NET -d $LAN_NET -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -i br0 -s ! $PROXY_IP -p tcp --dport 80 -j DNAT --to $PROXY_IP:$PROXY_PORT
iptables -t nat -I POSTROUTING -o br0 -s $LAN_NET -d $PROXY_IP -p tcp -j SNAT --to $LAN_IP
iptables -I FORWARD -i br0 -o br0 -s $LAN_NET -d $PROXY_IP -p tcp --dport $PROXY_PORT -j ACCEPT

现在,如果我只运行默认的squid.conf文件,我会在网络浏览器上看到以下页面:

ERROR
The requested URL could not be retrieved
The following error was encountered while trying to retrieve the URL: /questions/ask

Invalid URL

如您所见,' stackoverflow.com'从URL中截断:stackoverflow.com/questions/ask

现在,如果我将transparent更改为以下行:

http_port 3128 -> http_port 3128 transparent

网页浏览器中没有显示任何页面,我在&/39;`/var/log/squid/cache.log'中出现以下错误:

 NF getsockopt(SO_ORIGINAL_DST) failed on local=192.168.77.77:3128 remote=192.168.77.1:5268 FD 9 flags=33: (92) Protocol not available

我还有鱿鱼工作吗? google.com上没有任何参考资料似乎有所帮助。

1 个答案:

答案 0 :(得分:-1)

默认情况下,Squid会拒绝所有访问权限。您必须指定允许的人。

将此添加到您的acl列表

acl mycomputer src <yourip>

然后在拒绝所有

之前添加此权限
http_access allow mycomputer

# And finally deny all other access to this proxy
http_access deny all

在将它添加到squid.conf之前,我也遇到了相同或类似的错误。