Apache traffic forwarding - route incoming port 80 traffic for a particular host to a different physical server

StackOverflow https://stackoverflow.com/questions/17661721

Question

I have multiple web site hosts currently served by apache2's virtual hosts. I was wondering if it is possible to configure apache (or is some other tool more appropriate) to forward port 80 traffic destined for a particular host to a separate, actual server, that is the main server would serve most of the virtual hosts, but requests destined for www.myexample.com would be forwarded to a completely different server ?

Sorry if this question is common, but I do not even know what to search for to narrow down the list or responses that i am getting (most deal with setting up the virtual server, which I already have running).

Thanks Joe

Was it helpful?

Solution

I would use Nginx as a reverse proxy. There's some information on how to do that Here. Depending on the details of what you're trying to do, you might have a different configuration.

In addition to the tutorial above, here is some more information about Nginx and reverse proxies:

Reverse Proxy Module for Nginx
Reverse Proxy Wikipedia article

The way I would do it for your setup would be to make nginx the default httpd, by having it listen on port 80, then switch your Apache virtual configuration to 8080. Then just follow the links I've provided for a very vanilla style setup. Basically, you'll configure the new URL to forward to your other server in Nginx, then have all other URLs go to 8080, where it will hit your current Apache stack. If you were so inclined, you could move your Apache virtual servers down into the Nginx configs, but its not really necessary. Nginx reverse proxy on top of Apache is a fairly common configuration.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top