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 (192.168.1.10) server else to production (192.168.1.20). 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?
Asked
Active
Viewed 129 times
1
-
Your question is tagged [tag:reverse-proxy] and that is exactly what you need. – Michael Hampton Dec 17 '12 at 18:24
1 Answers
4
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.

Matthias Urlichs
- 425
- 2
- 9
-
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