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?
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.