我有 2 个应用程序在同一台服务器机器上的不同 tomcat 上运行
应用程序 1:www.example.com
应用程序 2:www.example.com/app
我已经对应用程序 1 进行了配置并且 SSL 工作,但对应用程序 2 不工作。
当我尝试访问 https:www.example.com/app 时,出现页面未找到异常
httpd.conf
ServerName example.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLEngine On
SSLCertificateFile /etc/ssl/certs/mydomain_com_with_chain.crt
SSLCertificateKeyFile /etc/ssl/private/mydomain_com.key
ProxyPass / http://myserver:8081/
ProxyPassReverse / http://myserver:8081/
ProxyPass /app http://myserver:8082/app
ProxyPassReverse /app http://myserver:8082/app
server.xml 配置正确,连接器具有代理参数
<Connector port="8081"
maxThreads="150"
minSpareThreads="25"
connectionTimeout="20000"
enableLookups="false"
maxHttpHeaderSize="8192"
protocol="HTTP/1.1"
useBodyEncodingForURI="true"
acceptCount="100"
disableUploadTimeout="true"
scheme="https"
proxyName="example.com"
proxyPort="443"
secure="true"/>
谁能指出这里的问题。我怀疑这是因为应用程序 1 没有上下文路径。但是,我的应用程序 1 没有上下文路径。 非常感谢任何建议。
最佳答案
如果您真的在 8081 和 8082 上运行两个 tomcat(因为您只提供一个连接器配置),这里是 mod_proxy documentation 的摘录(强调我的):
Ordering ProxyPass Directives
The configured ProxyPass and ProxyPassMatch rules are checked in the order of configuration. The first rule that matches wins. So usually you should sort conflicting ProxyPass rules starting with the longest URLs first. Otherwise, later rules for longer URLS will be hidden by any earlier rule which uses a leading substring of the URL. Note that there is some relation with worker sharing. In contrast, only one ProxyPass directive can be placed in a Location block, and the most specific location will take precedence.
这意味着它应该足以重新排序
ProxyPass /app http://myserver:8082/app
ProxyPassReverse /app http://myserver:8082/app
ProxyPass / http://myserver:8081/
ProxyPassReverse / http://myserver:8081/
此外,您可能想看看 Joao Vitorino 关于将第二个参数更改为 ProxyPassReverse 的答案 - 我通常不使用 ProxyPass 及其相关选项,所以我无法凭头脑判断。
丢失匹配的罪魁祸首似乎是第一个 ProxyPass,覆盖 /
,胜过第二个 /app
关于apache - 同一域中两个应用程序的 SSL 代理(一个应用程序没有上下文路径),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44907321/