เครือข่ายและ DNS

Transparent proxy in squid 2.6

การ config transparent proxy ตั้งแต่ squid version 2.6 เป็นต้นไป ได้เปลี่ยนการตั้งค่าใหม่โดยใช้

http_port 3128 transparent

แทนการตั้งค่าแบบเก่าที่ต้องมี configuration มากมายหลายบรรทัด ตามตัวอย่างด้านล่าง

http_port 3128
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

และให้เพิ่ม REDIRECT rule ของ iptables ด้วย จากข้างบนจะสามารถ config transparent proxy ได้ตามขั้นตอนด้านล่างดังนี้ แก้ไขไฟล์ /etc/squid/squid.conf โดยให้แก้ไขบรรทัด http_port เป็นดังนี้

http_port 3128 transparent

จากนั้นให้ restart squid ด้สนคำสั่ง

[root@zylinux ~]# service squid restart

เซ็ต iptables สำหรับการ redirect การร้องขอใช้งาน port 80 ไปยัง port 3128

[root@zylinux ~]# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

หลังจากทำตามขั้นตอนข้างต้นเสร็จแล้วทดสอบการใช้งานได้โดยให้เครื่อง client ชี้ gateway มาที่ squid server ตัวที่ได้ config ไว้ อ่านข้อมูลเพิ่มเติมสำหรับการ Setup squid transparent proxy ให้สามารถใช้ https

EOF.← กลับไปอ่านบทความอื่น