LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-20-2006, 11:20 PM   #1
Roddles
LQ Newbie
 
Registered: Nov 2005
Location: Sydney Australia
Distribution: Gentoo
Posts: 14

Rep: Reputation: 0
Question Routing based on Content??


Hi All

I am sure this has been covered before - but i have not been able to find any posts which satisfy what I am trying to acheive.

In a nut shell, I want to be able to host multiple web sites running on multiple servers (not just one server - so virtual web sites are not an option) all behind a single public IP address all coming through on port 80.

So if i had 3 domains ... www.siteA.com, www.siteB.com and www.siteC.com, they would all be listed on the public address of say 100.100.100.100 and all on port 80. The firewall can only have port 80 and 443 open - so I cant just use different ports.

What I am trying to figure out how to do is have the router (or app running on a linux box) examine the Host Header of the web request and route the request through to the appropriate server sitting behind my firewall, ie,

Domain Public Ip Port Internal Ip Port
www.siteA.com 100.100.100.100 80/443 192.168.1.10 80/443
www.siteB.com 100.100.100.100 80/443 192.168.1.20 80/443
www.siteC.com 100.100.100.100 80/443 192.168.1.30 80/443

The only differentiating information is the Host Header of the web request, so the routing would need to be done at the application Layer - not just the IP and Port layer.

Is there any way to actually acheive this on Linux? I know you can purchase devices for lots of $$ to do web routing or Content based routing, but i really dont want to fork out heaps of cash for a very small set up to rout between a few servers - and before anyone suggests that I just use virtual servers on apache - i need to use separate web servers - virtual is not an option.

Any assistance or advice on how to acheive this would be much appreciated.

Thanks in advance

Rod.
 
Old 11-21-2006, 01:40 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
there are dozens of ways to do this on linux, main one would be to use an apache front end with mod_proxy to redirect based on the Host header.
 
Old 11-21-2006, 02:37 AM   #3
Roddles
LQ Newbie
 
Registered: Nov 2005
Location: Sydney Australia
Distribution: Gentoo
Posts: 14

Original Poster
Rep: Reputation: 0
Talking

Thanks for the advice

I am learning how to set this up now. It looks like it might just do what I want.

Thanks for pointing me in the right direction

Regards

Rod.
 
Old 11-21-2006, 05:06 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
no probs. note of course that you could use one of these boxes for the front end function too, no need for dedicated hardware if you don't have it available.
 
Old 11-21-2006, 04:42 PM   #5
Roddles
LQ Newbie
 
Registered: Nov 2005
Location: Sydney Australia
Distribution: Gentoo
Posts: 14

Original Poster
Rep: Reputation: 0
Talking

I plan to have a dedicated virtual machine handling the routing. I have a pretty grunty dual core system with lots of ram available to me. This machine will be hosting several virtual machines - a mix of Windows and mainy Linux machines.

Thanks for your help

Cheers

Rod.
 
Old 01-09-2007, 07:19 PM   #6
mikesjays
Member
 
Registered: Dec 2005
Distribution: FC8, FC9, FC10
Posts: 30

Rep: Reputation: 16
Hey where could I find info on installing mod_proxy. I'm looking to have 2 servers behind a firewall also and I have no clue where to start.
 
Old 01-09-2007, 09:29 PM   #7
Roddles
LQ Newbie
 
Registered: Nov 2005
Location: Sydney Australia
Distribution: Gentoo
Posts: 14

Original Poster
Rep: Reputation: 0
If you are installing on an Ubuntu/Kubuntu server...

the proxy modules are already installed when you install apache2, well they were on each installation i did.

the following information is how I got apache2 reverse proxy working on Kubuntu Dapper 6.06

After you have installed apache2 through standard apt-get repositories...

cd /etc/apache2/sites-available

Now, you can either create a new file for each site that you want, or you can add the configuration to the default file. For mine, i just added the configuration into the default file as follows...

sudo nano default

Just under the NameVirtualHost * line, add the following for each internal server that you want to reverse proxy to...

<VirtualHost *>

ServerName www.externalsite1.com

ProxyRequests Off
ProxyPreserveHost On

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

ProxyPass / http://internalsite1.local/
ProxyPassReverse / http://internalsite1.local/

</VirtualHost>

Repeat the above code for each site that is being reverse proxied to, ie, if you have 2 internal web sites which are publically available through an external IP, the ServerName will be the external URL, such as www.ABC.com, and the internal servers will be www.internalabc.com - or whatever you use for your internal web servers.

Next, Enable the html proxy mod...

sudo a2enmod proxy

Then you have to restart apache...

sudo /etc/init.d/apache2 force-reload

Thats it. A gotcha to be careful of, if you are using DNS names such as URLs, then each machine resolving www.abc.com must resolve to the same IP address. If the calling machine resolves www.abc.com to 192.168.10.1, and the apache reverse proxy resolves www.abc.com to 222.123.54.123,, then the proxy will not work. they must all resolve to the same IP Address. (this is usually only a problem if you are editing host files to test machines before making changes). Just something to watch out for.

Hope this helps.

Cheers

Rod.
 
  


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
Port based routing neos Linux - Networking 1 09-21-2005 01:15 PM
Remove files based on content stefaandk Linux - General 2 08-13-2005 08:03 AM
renaming text files based upon a pattern in their content Spacepup Linux - General 1 07-28-2005 01:43 PM
Finding files based on content benjaminrtz Linux - General 2 08-04-2002 11:01 PM
Can iptables be configured to reject web requests based on content? steppin_razor Linux - Security 10 11-29-2001 12:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:29 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