Squid

ubuntu 14.04 伺服器上的透明 squid 代理

  • October 7, 2015

我的伺服器上安裝了 ubuntu 14.04 LTS 伺服器,我想在我的伺服器上安裝透明代理伺服器以用於 LAN 網路。請幫我解決一下這個。

提前致謝。

這很簡單,因為您已經擁有一台帶有 2 個以上 NIC 的 Ubuntu 機器——您只需要安裝或多或少的最新 Squid;您網路中的所有機器都必須使用 Squid box 作為預設網關;然後將以下內容添加到 squid 配置中:

# port configuration
http_port  3126 intercept
https_port 3127 intercept ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB cert=/opt/qlproxy/etc/myca.pem
http_port  3128 ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB cert=/opt/qlproxy/etc/myca.pem

最後使用 iptables 重定向來自埠 80 -> 3126、443 -> 3129 的傳入流量:

# redirect all HTTP(tcp:80) traffic coming in through eth0 to 3126
iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3126

# redirect all HTTPS(tcp:443) traffic coming in through eth0 to 3127
iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3127

啟用 NAT,一切順利。更多資訊請訪問http://blog.diladele.com/2014/04/10/transparent-ssl-https-filtering-on-centos/

在http://docs.diladele.com/tutorials/transparently_filtering_https_centos/index.html在 CentOS 7 上使用 FirewallD 更簡單

引用自:https://serverfault.com/questions/726959