วันจันทร์ที่ 5 พฤศจิกายน พ.ศ. 2555

วิธีการ Bypass บาง WebSite ไม่ให้ผ่าน Proxy

เนื่องจากว่า Proxy มีทั้งข้อดีและข้อเสีย

- ข้อดี คือ ทำให้เวปเร็วขึ้น
- แต่ข้อเสีย ก็คือ ทำให้เวปบางเวปช้าผิดปกติ หรือเข้าไม่ได้ หรือมีปัญหาเมื่อใช้งานผ่าน proxy

ยกตัวอย่างเช่น

การใช้งาน Web ข่าว www.thairath.co.th มาช้า หรือมาไม่ครบ ขาดๆ
หรือการเข้า Web www.icafeplus.net ไม่ได้  เป็นต้น

สามารถแก้ไขได้ดังนี้

ก่อนอื่นจะต้องทำการตรวจสอบก่อนว่า เวป ดังกล่าว มี ip อะไร

โดยใช้คำสั่ง nslookup จะได้ว่า

Name:    www.thairath.co.th
Address: 203.151.217.25, 203.151.217.76, 203.151.233.143

Name:   www.icafeplus.net
Address: 61.90.252.113

วิธีการคือ ให้เราทำการ -j ACCEPT ip ดังกล่าว ก่อนจะทำการ -j REDIRECT

โดยสามารถเข้าไปแก้ในไฟล์  /etc/init.d/tproxy.shฟ

โค๊ด:
#!/bin/bash

# This file is auto generate by xxxkung script

iptables -t nat -F TPROXY

### Bypass www.icafeplus.net
iptables -t nat -A TPROXY -i eth0 -d 61.90.252.113 -j ACCEPT

### Bypass www.thairath.co.th
iptables -t nat -A TPROXY -i eth0 -d 203.151.217.25 -j ACCEPT
iptables -t nat -A TPROXY -i eth0 -d 203.151.233.143 -j ACCEPT
iptables -t nat -A TPROXY -i eth0 -d 203.151.217.76 -j ACCEPT

### Redirect Trickster
iptables -t nat -A TPROXY -i eth0 -p tcp -d 61.90.203.0/24 --dport 5977 -j REDIRECT --to-port 8080
### Redirect Normal Web Port
iptables -t nat -A TPROXY -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

เป็นต้น

ลองนำไปทดลองกันดูนะครับ

ไม่มีความคิดเห็น:

แสดงความคิดเห็น