Apache Port Proxy

Dave picture Dave · Jul 22, 2009 · Viewed 44.7k times · Source

I have a non-Apache server listening to port 8001 and Apache listening port 80. I want a certain virtual domain to actually be served by the non-Apache server over port 80.

Example:

<VirtualHost *:80>
  Servername example.com

  # Forward this on to the server on port 8001
</VirtualHost>

I thought I could do this with mod_proxy and ProxyPass with something like this.

ProxyPass * http://www.example.com:8001/

But that doesn't work.

Answer

txyoji picture txyoji · Aug 10, 2009

ProxyPass * http://www.example.com:8001/

star is only valid in a block. Forward slash is what you want.

ProxyPass / http://www.example.com:8001/
ProxyPassReverse / http://www.example.com:8001/

The reverse proxy ensures that redirects sent by your port 8001 server are adjusted to the canonical name name of your proxy.

The apache manual has some examples. http://httpd.apache.org/docs/2.0/mod/mod_proxy.html