I'm trying to figure out how to proxy requests to subdomains of localhost to another port on Apache, but not proxy requests only to localhost (with no subdomains). I can't get it to work. Here is what I have come up with so far.
<VirtualHost *:80>
ServerName subdomain1.localhost
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
ServerName subdomain2.localhost
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
NoProxy "localhost"
</VirtualHost>
The proxying of subdomain1 and subdomain2 to localhost:3000 works, but localhost is also proxied to localhost:3000. How do I prevent that?
EDIT
With the help of @Esa and @HBruijn but I still can't get it to work. I've edited virtual hosts the http.conf to the following. The aliases work but now the subdomains don't work.
<VirtualHost *:80>
ServerName localhost
Alias /alias1 "/alias1"
Alias /alias2 "/alias2"
Alias /alias3 "/alias3"
</VirtualHost>
<VirtualHost *:80>
ServerName subdomain1.localhost
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
<VirtualHost *:80>
ServerName subdomain2.localhost
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>