LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-25-2009, 10:11 AM   #1
Yahooguntu
LQ Newbie
 
Registered: Aug 2009
Posts: 7

Rep: Reputation: 0
Iptables and Name-Based Virtual Hosting


I am building an iptables-based gateway that will route traffic from the WAN to two different servers on the LAN. One server is using name-based virtual hosting for two websites, and the other will be running one or more websites in the future. If the gateway has only one WAN IP address, is there some way for iptables to route incoming traffic based on the "Host" HTTP header? If not, is there a way to go about doing this?

Thank you for your time.
 
Old 08-25-2009, 10:28 AM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
You cannot solve this problem below the application layer, since a TCP connection needs to be opened to the correct web server even before any application data (e.g. the "Host:" header) is sent. Look in the direction of reverse proxies for a possible solution. Welcome to LinuxQuestions.
 
Old 08-26-2009, 08:35 AM   #3
Yahooguntu
LQ Newbie
 
Registered: Aug 2009
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for your help. I looked up "reverse proxy" on Wikipedia, and there seem to be a lot of choices. Can anyone recommend one? Load balancing might be needed in the future.
 
Old 08-26-2009, 09:20 AM   #4
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by Yahooguntu View Post
Thanks for your help. I looked up "reverse proxy" on Wikipedia, and there seem to be a lot of choices. Can anyone recommend one? Load balancing might be needed in the future.
Code:
http://wiki.nginx.org/Main
never used it but heard some good things about it
 
Old 08-26-2009, 09:44 AM   #5
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
well i did something like this i have two virtual hosts running on a single box listening on ips 40000 and 40002 on the firewall which has 1 wan interface , i did a portforwarding using iptables,something like this

iptables -t nat -I PREROUTING -p tcp -s 0.0.0.0/0 -d 124.0.0.0/8 --dport 20000 -j DNAT --to-destination 192.168.1.2:40000

iptables -t nat -I PREROUTING -p tcp -s 0.0.0.0/0 -d 124.0.0.0/8 --dport 20002 -j DNAT --to-destination 192.168.1.2:40002

Last edited by kdelover; 08-26-2009 at 09:45 AM.
 
Old 08-26-2009, 07:27 PM   #6
Yahooguntu
LQ Newbie
 
Registered: Aug 2009
Posts: 7

Original Poster
Rep: Reputation: 0
So if I were setting this up with a reverse proxy, would iptables need to route incoming traffic to the proxy or to the destination interface? Does the proxy intercept traffic going onto the LAN, or does the traffic need to be directed there? Also, would iptables need to be set up somehow to route traffic from the proxy to the LAN?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
virtual name based hosting atomicrm Linux - Server 8 12-17-2009 09:20 AM
post based virtual hosting sulekha Linux - Server 1 11-16-2008 10:38 AM
Apache and IP - Based virtual Hosting shawnbishop Linux - Software 2 10-27-2006 09:56 AM
name based virtual hosting jkmartha Linux - Software 4 08-04-2005 09:21 AM
name based virtual hosting adm1329 Linux - Networking 5 05-05-2004 11:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration