Subdomain under Apache to proxy into Tomcat

陌路散爱 提交于 2019-12-06 10:50:59

问题


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?


回答1:


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




回答2:


This should probably be moved to superuser.com but one thing to try:

<VirtualHost *:80> informs it to accept all incoming connections on port 80 to use these settings. I would try changing it to say:

<VirtualHost subdomain.localhost:80>

and see if that only applies these settings when the subdomain is used.

The ServerName tag that you put with the subdomain doesn't tell it who to listen for. The official documentation states:

The ServerName directive sets the hostname and port that the server uses to identify itself. This is used when creating redirection URLs. For example, if the name of the machine hosting the web server is simple.example.com, but the machine also has the DNS alias www.example.com and you wish the web server to be so identified, the following directive should be used:

You can read more on these configurations here.



来源:https://stackoverflow.com/questions/2608705/subdomain-under-apache-to-proxy-into-tomcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!