天天看點

Haproxy全透明代理

作業系統Centos7 核心版本3.10

Centos7已自帶TPROXY子產品,不需要安裝TPROXY

編譯安裝

配置

用戶端與後端伺服器均為window7 ,haproxy為centos7

iptables配置

iptables -F

iptables -t mangle -N DIVERT

iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT

iptables -t mangle -A DIVERT -j MARK --set-mark 222

iptables -t mangle -A DIVERT -j ACCEPT

ip rule add fwmark 222 lookup 100

ip route add local 0.0.0.0/0 dev lo table 100

haproxy 網卡enp0s8的ip位址為 10.17.12.192

添加轉發和重定向

配置路由

最終路由結果

用戶端測試軟體截圖:

Haproxy全透明代理

服務端測試軟體截圖

Haproxy全透明代理

<a href="http://www.haproxy.com/blog/howto-transparent-proxying-and-binding-with-haproxy-and-aloha-load-balancer/">http://www.haproxy.com/blog/howto-transparent-proxying-and-binding-with-haproxy-and-aloha-load-balancer/</a>

<a href="http://techblogsearch.com/a/haproxy-transparent-mode-on-centos-7.html">http://techblogsearch.com/a/haproxy-transparent-mode-on-centos-7.html</a>

<a href="http://www.360doc.com/content/13/0821/17/13047933_308812287.shtml">http://www.360doc.com/content/13/0821/17/13047933_308812287.shtml</a>

<a href="https://wenku.baidu.com/view/335db66a376baf1ffc4fade1.html">https://wenku.baidu.com/view/335db66a376baf1ffc4fade1.html</a>

<a href="http://cbonte.github.io/haproxy-dconv/1.4/configuration.html">http://cbonte.github.io/haproxy-dconv/1.4/configuration.html</a>

<a href="http://blog.sina.com.cn/s/blog_704836f401011e17.html(%E7%AC%AC%E4%B8%80%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99)">http://blog.sina.com.cn/s/blog_704836f401011e17.html(第一參考資料)</a>

QQ:519841366

本頁版權歸作者和部落格園所有,歡迎轉載,但未經作者同意必須保留此段聲明,

且在文章頁面明顯位置給出原文連結,否則保留追究法律責任的權利

繼續閱讀