Search code examples
apachetomcatproxysubdomainajp

Subdomain under Apache to proxy into Tomcat


I'm having trouble with making a subdomain to my Windows computer while using AJP to proxy to Tomcat. This is what I have in my httpd.conf file:

<VirtualHost *:80>  
    ServerName subdomain.localhost  
    ProxyRequests Off  
    <Proxy *>  
        Order deny,allow  
        Allow from all  
    </Proxy>  
    ProxyPass / ajp://localhost:8009/folder/  
    ProxyPassReverse / ajp://localhost:8009/folder/  
    <Location />  
        Order allow,deny  
        Allow from all  
    </Location>  
</VirtualHost>

The subdomain has been added to `c:\windows\system32\drivers\etc\hosts

127.0.0.1 localhost
127.0.0.1 subdomain.localhost

When I go to http://localhost i goes straight to the proxy. When I go to http://subdomain.localhost i goes to the proxy as well. How do I make is so the subdomain only goes to the proxy and the regular goes to Apache?


Solution

  • You need to declare a second VirtualHost with localhost as the ServerName.