6

Let's say the I have a web server running on port 3000, so example.com:3000 and another one on the 80, so: example.com

Is it possible to map example.com/map to example.com:3000 ?

I would like to map a directory to a different port of a different Apache installation, but I would like to hide the 3000 number.

Thanks.

4 Answers 4

2
  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.
4

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.

1

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

1
  • This is the correct answer Aug 17, 2012 at 18:42
0

The simplest way I think is to have two VirtualHosts.

Listen 80
Listen 3000

<VirtualHost a.b.c.d:80>
DocumentRoot /html
</VirtualHost>

<VirtualHost a.b.c.d:3000>
DocumentRoot /html/map
</VirtualHost>
1
  • But I was talking about two different Apache servers in the same computer.
    – rtacconi
    Sep 7, 2009 at 9:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .