Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This is obviously possible because its what all webfarms do, however I'm not a webfarm.

I do have pretty good technical ability primarily windows, but would happily setup a simple linux box to achieve this.

At the moment I have an internet facing router, which allows traffic through to one machine on various ports. This works fine and I can run multiple websites on that one machine, however I would like to be able to intercept traffic and send to seperate machines based on domain name.

Reporting.example.com => PC1
Demos.example.com => PC2
MySite.example.com => PC1
Three.example.com => PC3
(all domain obviously resolve to my single internet facing IP address).

Can I get a router that will do this (I know about port forwarding etc, but they only work on ports), can I set up an intermediate linux/XP box with a forwarder? Is there an easy solution?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

This is not the only way or the best way but this is how I would go about it. Correct me if I misunderstood any facts in your question

  1. Router holds WAN IP. If you router allows specifying hostname to ip mapping you can try to add that by mapping each domain to the internal IP of your network.

  2. If the router can't do that you can setup a reverse proxy on one system to forward traffic by domain to backend systems. This is handy as you can use it for failover as well.

here is an example vhost config of apache as reverse proxy.

ServerName Demos.example.com
ProxyPreserveHost On
ProxyTimeout 5400
ProxyPass / http://LAN_IP1 max=20 ttl=5000 retry=300
ProxyPassReverse / http://LAN_IP1/

p.s. You do not need to have a dedicated reverse proxy server, you can use one of the existing systems to do that and this can serve one domain locally and proxy out other domains. This particular system must be the one your router forwards all web traffic to.

share|improve this answer
    
i'll try this out thanks –  Toby Allen Apr 15 '12 at 12:27
add comment

Vangels solution worked great, I have clarified here for anyone else.

This needs to go in the http.conf file

<VirtualHost *:80> 
 ServerName Demos.example.com
 ProxyPreserveHost On
 ProxyTimeout 5400
 ProxyPass / http://LAN_IP1 max=20 ttl=5000 retry=300
 ProxyPassReverse / http://LAN_IP1/
</VirtualHost >

You also need to enable the following Modules

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.