I would like to do the following thing: I have a host server with two virtual webservers installed on it. First virtual webserver is production and second is development. In my DNS I have binded lets say example.com to my external IP, and in iptables I did port forwarding (port 80 to production server) but now i would like to change this logic to the following: if domain is dev.example.com I would like to forward traffic to development ( server else to production ( I have read some articles on how to do this with iptables but they wasnt really sure if this is possible, I also have the idea to do this with proxy (like squid). I know I can do this with php script (to forward all traffic to forward.php and then redirect to ip, but I REALLY DONT want to do this). Are there any sollutions to do this, because I was unable to find them after few hour research?


You need an HTTP proxy for that. One good option is haproxy (http://haproxy.1wt.eu/).

Personally, I would try to get a second IP address for development. It's too easy to mess something up otherwise.

  • yes but If i want second IP I need it to be public and that is to expensive for me (as a student), how about squid proxy? – gGololicic Dec 17 '12 at 15:55
  • Sure, you can use squid. But it's rather large and may interfere with testing your development site. I prefer a dedicated non-caching proxy for your usecase – you probably can install and configure haproxy in half the time it takes to read and understand all the options in squid's configuration file. – Matthias Urlichs Dec 17 '12 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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