การทำ Transparent Proxy


การทำ Transparent Proxy

การทำ Transparent Proxy

เป็นการบังคับให้เครื่องลูกต้องผ่าน Proxy Server โดยที่ไม่ต้องไป set proxy ที่ตัว Browser ทำโดยเพิ่มเข้าเข้าไปใน squid.conf ดังนี้

http_port 8080
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

ตอนที่เรา vi /etc/squid/squid.conf ให้พิมพ์ดังข้างล่างนี้ดังต่อไปนี้

http_port 8080
icp_port 3130
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 128 MB     ;<==== แนะนำว่า เอา Ram/3
cache_replacement_policy heap GDSF
memory_replacement_policy heap GDSF
cache_dir diskd /cache 1000 16 256  ;<==== ที่เก็บ Cache
cache_store_log none
acl localnet src 192.168.1.0/255.255.255.0
acl localhost src 127.0.0.1/255.255.255.255
acl Safe_ports port 80 443 210 70 21 1025-65535
acl CONNECT method CONNECT
acl all src 0.0.0.0/0.0.0.0
http_access allow localnet
http_access allow localhost
http_access deny !Safe_ports
http_access deny CONNECT
http_access deny all
cache_mgr root
cache_effective_user squid
cache_effective_group squid
logfile_rotate 0
log_icp_queries off
cachemgr_passwd my-secret-pass all
buffered_logs on
httpd_accel_host virtual    
 ;<=== สี่บรรทัดที่เพิ่มเข้ามาข้างล่างนี้
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

จากนั้นเพิ่ม iptables อีกบรรทัด ดังนี้

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

[root@one root]# /etc/init.d/iptables save
[root@one root]# /etc/init.d/iptables restart
Flushing all current rules and user defined chains:    [ OK ]
Clearing all current rules and user defined chains:    [ OK ]
Applying iptables firewall rules:             [ OK ]
                              [ OK ]
[root@one root]#

สั่งให้ squid ทำงานโดย /etc/inet.d/squid restart

[root@one root]# /etc/init.d/squid restart
Stopping squid: .                     [ OK ]
Starting squid:                      [ OK ]
[root@one root]

เป็นการเสร็จสิ้นการทำ Transparent Proxy

คำสำคัญ (Tags): #การทำ transparent proxy
หมายเลขบันทึก: 105209เขียนเมื่อ 21 มิถุนายน 2007 17:50 น. ()แก้ไขเมื่อ 16 มิถุนายน 2012 16:02 น. ()สัญญาอนุญาต: จำนวนที่อ่านจำนวนที่อ่าน:


ความเห็น (0)

ไม่มีความเห็น

พบปัญหาการใช้งานกรุณาแจ้ง LINE ID @gotoknow
ClassStart
ระบบจัดการการเรียนการสอนผ่านอินเทอร์เน็ต
ทั้งเว็บทั้งแอปใช้งานฟรี
ClassStart Books
โครงการหนังสือจากคลาสสตาร์ท