Squid+iptables:如何允许 https 传递并绕过 Squid?
今天基本上是从 Squid 和 iptables 开始的(google 是你的朋友)。这东西会害死我的。
我在 Ubuntu 9.04 服务器上设置了 Squid3 作为透明代理。当我使用代理盒作为我的默认网关等时,它工作得很好。此设置的 iptable 规则是教程的一部分。 :P
不幸的是,我无法访问 https 网站(例如 Gmail 或基本上端口 443 上的任何内容)。这是因为 Squid 不喜欢它无法缓存的内容,在本例中是 https 流量。
我想添加一个 iptable 规则,以便我基本上可以访问 https 站点并使用 Skype。基本上允许这些类型的流量通过而不经过Squid代理? (可以这么说,绕过它)
有人可能知道如何做到这一点,或者有任何来源的链接可以帮助我解决这个问题吗?
谢谢。
Basically started with Squid and iptables today (google is your friend). This stuff is going to be the death of me.
I have Squid3 setup on Ubuntu 9.04 server as Transparent Proxy. It works sweetly when i use the proxy-box as my default gateway etc. The iptable rules for this setup was part of the tutorial. :P
I can unfortunately not access https sites (such as Gmail or anything on port 443 basically). This is because Squid dont like what it cannot cache, which in this case is the https traffic.
I would like to add an iptable rule so that i can basically access https sites and use Skype. Basically allow these types of traffic to pass through without going through Squid proxy? (bypassing it so to speak)
Would anyone perhaps know how to do this or have a link to any sources that would assist me in figuring it out?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在真正考虑过咀嚼自己的手腕并整夜梦想着 IP + 强力谷歌搜索/尝试任何我可以用数字手指操作的东西之后,我设法将一些实际有效的东西组合在一起。我不知道其中的技术原因,所以如果您可以提供固定的解释,请这样做! :D
PS:解释中的所有内容都是通过命令行完成的
PS:这不是最终的解决方案,但它是回答我自己的问题的有效解决方案。
这里是:
第 1 步:必须在盒子上启用 IP 转发:
// 找到并取消注释以下
第 2 步:添加环回规则(这更多的是当所有端口都被覆盖时) ,显然很多应用程序都需要它?
步骤3.添加绕过端口443的规则:(eth1是互联网接口,xxxx/eth0是LAN接口)
步骤4.然后最后是使Squid透明的规则:(xxxx是LAN接口的IP)
After actually considering chewing through my own wrists and dreaming of IPs all night long + brute force googling/trying ANYTHING i could get my digital fingers on i managed to put something together that actually works. I dont know the technical reasons why, so if you can provide set explanations please do so! :D
PS: everything in the explanation is done via command line
PS: this is not a final solution, but its a working one in answer to my own question.
Here it is:
Step 1: Had to enable IP Forwarding on the box:
//find and uncomment the following
Step 2: Add loop back rule (this is more for when all ports are covered, apparently many apps need it?
Step 3. Add rules for the bypassing of port 443: (eth1 is internet interface and x.x.x.x/eth0 is LAN interface)
Step 4. Then finally the rules making Squid transparent:(x.x.x.x is IP of LAN interface)
那是错误的。意味着您从内部 LAN 发送到 Internet 的每个数据包
TCP/UDP/etc
都将使用专用 LAN IP(可能是 192.178.xx)作为源 IP,而不是公共 IP。可能对您有帮助:
绕过 443 就足够了:
如果您的
system/squid/firewall
也是从您的网络到互联网的路由器,请不要忘记:That is wrong. Means that every packet
TCP/UDP/etc
that you send from your intern LAN to Internet will use as SOURCE IP the Private LAN IP (probably 192.178.x.x), instead of the Public IP.May be that helps you:
To bypasss 443 would be enough with:
And if your
system/squid/firewall
is also the router from your network to internet, do not forget:对于这些解释...
步骤 #1 将机器设置为路由器。对于任何要接受或转发发往除自身之外的计算机的 IP 流量的 Linux 计算机,这是必需的。如果没有这个,网络堆栈的最低级别将拒绝流量,NAT 甚至没有机会做它的事情。
步骤#2 与所询问的问题无关。与代理无关的路由器操作可能需要也可能不需要。
步骤#3 让机器正常中继端口 443 作为路由器。使用 MASQUERADE 代替 SNAT 可以使 POSTROUTING 规则变得更好。
步骤#4 两条线以不同的方式做同样的事情。如果您不知道 DNAT 和 REDIRECT 之间的区别,第一行可能会给您带来麻烦。为简单起见,仅使用“重定向”。
阅读http://wiki.squid-cache.org/ConfigExamples/Intercept/LinuxRedirect 可以为你省去很多麻烦。
您的设置中还缺少一个关键的 mangle 表规则,该规则在该 wiki 页面上进行了解释。
For those explanations...
step #1 sets up the machine as a router. This is required for any Linux machine that is going to accept or forward IP traffic destined for machines other than itself. Without this the lowest levels of the networking stack will reject the traffic and NAT will not even get a chance to do its thing.
step #2 is not relevant to the problem being asked about. It may or may not be needed for the router operations unrelated to the proxying.
step #3 lets the machine relay port 443 normally as a router. The POSTROUTING rule could be made better by using MASQUERADE instead of SNAT.
step #4 both lines do the same thing in different ways. The first line may lead you to trouble in future if you dont know what the differences are between DNAT and REDIRECT. For simplicity use REDIRECT only.
Reading http://wiki.squid-cache.org/ConfigExamples/Intercept/LinuxRedirect could have saved you a lot of trouble.
There is also a critical mangle table rule missing from your setup which is explained on that wiki page.