免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4901 | 回复: 5
打印 上一主题 下一主题

[proxy] squid v2.7透明代理问题 [复制链接]

论坛徽章:
4
IT运维版块每日发帖之星
日期:2015-09-01 06:20:00IT运维版块每日发帖之星
日期:2015-10-09 06:20:00操作系统版块每日发帖之星
日期:2015-10-20 06:20:00IT运维版块每日发帖之星
日期:2015-11-03 06:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-04 10:49 |只看该作者 |倒序浏览
20可用积分
外网地址:172.19.3.2   eth0
内网地址:192.168.1.1  eth1
系统:centos 5.2

做了SNAT
/sbin/iptables -t nat -A POSTROUTING -s 192.168.1.0/255.255.255.0 -o eth0 -j SNAT --to-source 172.19.3.2
其它机器填写网关为192.168.1.1 都可以上网

我将squid监听的端口写为 http_port 192.168.1.1:3128
然后在浏览器里将IE的代理地址写为192.168.1.1  端口为3128,无法上网。于是添加规则
/sbin/iptables -A INPUT -s 192.168.1.0/24 --dport 3128 -j ACCEP这段也就是对内网用户开放3128端口,客户机在IE浏览器里更改代理服务器地址改端口为192.168.1.1:3128 ,结果还是无法上网,于是关闭防火墙,代理服务器就可以上网了!

当前防火墙的规则
[root@www etc]# /sbin/iptables -t nat -F
[root@www etc]# /sbin/iptables -t filter -F
[root@www etc]# /sbin/iptables -t nat -A POSTROUTING -s 192.168.1.0/255.255.255.0 -o eth0 -j SNAT --to-source 172.19.3.2
[root@www etc]# /sbin/iptables -A INPUT -i eth1 -p tcp -m tcp --dport 3128 -j ACCEPT
[root@www etc]# /sbin/iptables -A OUTPUT -p tcp -m tcp -d 0/0 -j ACCEPT
[root@www etc]# /etc/init.d/iptables save
将当前规则保存到 /etc/sysconfig/iptables:                 [确定]
[root@www etc]# /etc/init.d/iptables restart
客户机使用网关可以上网,但使用代理就不可以上网了!这说明还是防火墙的问题!麻烦squid佬大您给帮帮忙。要解决的问题: squid监听的IP地址及端口是在内网的那块网卡上. 现在我要允许所有来自192.168.1.0/24网络的用户使用SQUID上网,其它用户禁止!  iptables规则如何设置.或者弄成透明代理也行的!关闭防火墙的情况下,Squid可以正常使用.麻烦您将以下的文件改成透明代理
我的squid.conf配置文件:
#Squid Ver 2.7     

http_port 192.168.1.1:3128
cache_mem 200 MB
maximum_object_size 8000 KB
maximum_object_size_in_memory 8128 KB

dns_nameservers 61.128.114.133
cache_dir ufs /var/squid/cache 8000 16 256
error_directory /usr/local/squid/share/errors/Simplify_Chinese

acl nocache urlpath_regex cookie.*\.php *\.jsp *\.asp
no_cache deny nocache

acl btfile urlpath_regex -i .torrent$
http_access deny btfile

acl notbt url_regex -i btn
http_access deny notbt


cache_access_log /var/squid/access.log
cache_log /var/squid/cache.log
cache_store_log /var/squid/store.log

acl localhost src 172.19.3.0/24
http_access allow localhost

acl local src 192.168.1.0/24
http_access allow local

acl all src 0.0.0.0/0.0.0.0
http_access deny all

acl safe port 80 21 443 3128
http_access allow safe

cache_effective_user squid
cache_effective_group squid
cache_mgr wubifans_huaxing@yahoo.com.cnvisible_hostname ProxyServer
icon_directory /usr/local/squid/share/icons

ipcache_size 1024
ipcache_low 90
ipcache_high 95
fqdncache_size 1024

论坛徽章:
0
2 [报告]
发表于 2008-12-05 09:30 |只看该作者
1.  透明代理你的第一行http_port 192.168.1.1:3128 transparent是要加的

2.  acl localhost src 172.19.3.0/24
     http_access allow localhost  //如果只要192.168.1.0/24可代,这两句要去掉


3.  你可以改动上面两个地方,关闭防火墙,看看透明代理行不行,如果可行,你再把iptables的规则慢慢加进去

论坛徽章:
4
IT运维版块每日发帖之星
日期:2015-09-01 06:20:00IT运维版块每日发帖之星
日期:2015-10-09 06:20:00操作系统版块每日发帖之星
日期:2015-10-20 06:20:00IT运维版块每日发帖之星
日期:2015-11-03 06:20:00
3 [报告]
发表于 2008-12-05 11:02 |只看该作者
http_port 192.168.1.1:3128 transparent
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_user_host_header on

加入了这几行了

错误提示如下:
[root@www squid]# sbin/squid -k shutdown
2008/12/05 10:59:27| parseConfigFile: squid.conf:59 unrecognized: 'httpd_accel_
ost'
2008/12/05 10:59:27| parseConfigFile: squid.conf:60 unrecognized: 'httpd_accel_
ort'
2008/12/05 10:59:27| parseConfigFile: squid.conf:61 unrecognized: 'httpd_accel_
ith_proxy'
2008/12/05 10:59:27| parseConfigFile: squid.conf:62 unrecognized: 'httpd_accel_
ser_host_header'

论坛徽章:
0
4 [报告]
发表于 2008-12-05 13:28 |只看该作者
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_user_host_header on

全部干掉,你要是用的2.7以上,这几行没必要加了

论坛徽章:
4
IT运维版块每日发帖之星
日期:2015-09-01 06:20:00IT运维版块每日发帖之星
日期:2015-10-09 06:20:00操作系统版块每日发帖之星
日期:2015-10-20 06:20:00IT运维版块每日发帖之星
日期:2015-11-03 06:20:00
5 [报告]
发表于 2008-12-05 13:31 |只看该作者
哪现在怎么支持透明代理呀!
在安装有SQUID的电脑上,将来自内网的dport 80数据包重定向到3128就搞定了吗

论坛徽章:
0
6 [报告]
发表于 2008-12-05 14:48 |只看该作者
没错,透明就是不用用户自己设置代理了,本质上就是通过iptables来转发包的
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP