PDA

View Full Version : การ config Apache2 เพื่อทำ reverse proxy ให้เข้าถึงเครื่องใน internal network



asylu3
02-05-2008, 01:34 AM
หากท่านมีเว็บหลักที่สามารถเปิดได้ที่ไหนในโลก เช่น citecclub.org
แต่มี server ในองค์กรที่ไม่ไดสามารถเข้าถึงได้โดยตรงอยู่ชื่อ mylocalhost.com (ชื่อปลอมๆตั้งขึ้นมาให้รู้จักภายในวง network) เชื่อมกับ citecclub.org อยู่ด้านหลัง

แล้วอยากให้ทุกครั้งที่ผู้ชมเรียก
้ http://citecclub.org/somewhere
ไปเรียก
http://mylocalhost.com/somewhere (http://citecclub.org/forum/redirector.php?url=http%3A%2F%2Fmylocalhost.com%2Fsomewhere)
มาแสดงผล

สามารถปรับแต่ง apache ได้ดังนี้[hide=1]
ปล. อ้างอิง Ubuntu
พิมพ์คำสั่งนี้

#a2emod
แล้วเลือก enable: proxy และ proxy_http

edit /etc/apache2/mod-enabled/proxy.conf ดังนี้




<IfModule mod_proxy.c>
#turning ProxyRequests on and allowing proxying from all may allow
#spammers to use your proxy to send email.

ProxyRequests Off

<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
</Proxy>

# Enable/disable the handling of HTTP/1.1 "Via:" headers.
# ("Full" adds the server version; "Block" removes all outgoing Via: headers)
# Set to one of: Off | On | Full | Block

ProxyVia On

ProxyPass /somewhere http://mylocalhost.com/somewhere
ProxyPassReverse /somewhere http://mylocalhost.com/somewhere

</IfModule>




จากนั้นก็ให้โหลด module มาใช้งาน /etc/init.d/apache2 force-reload
เท่านี้ก็สามารถเรียกใช้งาน content ที่อยู่ใน server ที่ไม่สามารถเข้าถึงจาก Public internet ตรงๆได้แล้ว

asylu3
07-05-2008, 01:25 AM
เสริมนิดนึงถ้า config แล้วไม่ระวังเรื่อง / จะทำให้ Access ไปเครื่องด้านหลังไม่ได้ต้องระวังให้ดี