Apache map port to url

Solution 1:

  1. you can use mod_proxy to match the URL and proxy the connection to port 3000
  2. If you do not require complete abstraction of port 3000, you can use mod_rewrite to match the URL and rewrite it to what the apache on port 3000 would serve.

Solution 2:

Use an HTTP proxy that listens on port 3000. If you try to use the rewriter, it will force a client-side redirect, which will not be what you are after.

Solution 3:

I know you can map virtual hosts to different ports using different sites like examlple1.com and example2.com - that's just in vhosts it's pretty easy.

Listen 80
Listen 8080

NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080

<VirtualHost 172.20.30.40:80>
ServerName www.example1.com
DocumentRoot /www/domain-80
</VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example1.com
DocumentRoot /www/domain-8080
</VirtualHost>

<VirtualHost 172.20.30.40:80>
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
</VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080
</VirtualHost>

But if you want to map a subdirectory to a different port I don't think you can do that without URL Rewriting on the backend so they didn't know it was happening - it wouldn't be very clean. You could do it relatively easily if you made it a subdomain like map.example.com