简体   繁体   English

从Apache到Tomcat的子域ajp代理

[英]Subdomain ajp proxy from Apache to Tomcat

I have a domain domain.com that points to a server. 我有一个指向服务器的域domain.com。 Now I have a subdomain sub.domain.com that points to another server that has Apache running and Tomcat. 现在,我有一个子域sub.domain.com指向另一个运行Apache和Tomcat的服务器。

I have configured the following in httpd.conf: 我已经在httpd.conf中配置了以下内容:

<VirtualHost *:80>
    ServerName domain.com
    ProxyRequests Off
    ProxyPreserveHost On
    <Proxy *>
    Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/
</VirtualHost>

<VirtualHost *:80>
    ServerName sub.domain.com
    ProxyRequests Off
    ProxyPreserveHost On
    <Proxy *>
    Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/
</VirtualHost>

and in Tomcats server.xml: 并在Tomcats server.xml中:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

But when I go to sub.domain.com it goes to otherdomain.com and shows me this php website declared as following: 但是,当我转到sub.domain.com时,它会转到otherdomain.com并向我显示此php网站声明如下:

<VirtualHost *:80>
        DocumentRoot /var/www/html/otherdomain.com
        ServerName otherdomain.com
        ServerAlias www.otherdomain.com
</VirtualHost>

I only get it to work when I change the port in both domain.com and sub.domain.com virtual host declarations to something like 8001. Then when I go to sub.domain.com:8001 it shows my tomcat application (ROOT.war). 只有将domain.com和sub.domain.com虚拟主机声明中的端口都更改为类似8001的端口时,它才能工作。然后,当我访问sub.domain.com:8001时,它显示了我的tomcat应用程序(ROOT。战争)。

So my question is: what could be going wrong that it doesn't work with the default port 80? 所以我的问题是:在默认端口80下无法正常工作是怎么回事? I can't find any configuration that is causing this, but I'm probably missing something? 我找不到导致此问题的任何配置,但我可能丢失了一些东西?

Apparently my configuration is correct after all. 显然我的配置毕竟是正确的。 It was just my browsers cache playing tricks on me. 只是我的浏览器缓存了对我的欺骗。 I have caching now disabled when developing to not have this happening again. 现在,我在开发时已禁用缓存,以免再次发生这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM