我在端口 8080 上有一个正在运行的 Tomcat 应用程序 (Alfresco),而我需要在端口 443 上运行该应用程序,从 Apache 转发(Apache 已经在该服务器上处理许多其他 SSL 端点)。
这可行,但我不太明白为什么。我的设置是:
mod_jk
。连接器处理 URL https://example.com/alfresco
和 https://example.com/share
,它们之前明确位于端口 8080。 worker.properties
设置为转发到端口 8009server.xml
包含以下连接器定义: <!-- Question: what is this for? -->
<Connector port="8080" protocol="HTTP/1.1"
URIEncoding="UTF-8" connectionTimeout="20000"
maxHttpHeaderSize="32768" redirectPort="8443"
enableLookups="false" xpoweredBy="false" server="AlfrescoECM"
maxParameterCount="1000"/>
<!-- Alfresco requires an HTTPS connection to Solr on port 8443 -->
<Connector port="8443" protocol="HTTP/1.1"
SSLEnabled="true" maxThreads="150" scheme="https"
...
sslProtocol="TLS" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector protocol="AJP/1.3"
port="8009" redirectPort="8443"
maxParameterCount="1000" secretRequired="false" />
如果我省略端口 8080 的连接器,这将不起作用:
INFO [webscripts.connector.RemoteClient] [ajp-nio-127.0.0.1-8009-exec-3] Exception calling (GET) http://localhost:8080/alfresco/s/api/admin/restrictions?guest=true
org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1] failed: Connection refused
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156) ~[httpclient-4.5.13.jar:4.5.13]
...
Caused by: java.net.ConnectException: Connection refused
问题:为什么我还需要 8080 端口的连接器?这一切不应该由 AJP 来处理吗?
在您的情况下,tomcats 端口 8009 上的 ajp 连接器仅用于来自充当反向代理的 apache 的最终用户请求。如果您需要处理 443 上的最终用户请求,您应该仅在 apache 端定义它。 对于 Alfresco,端口 8080/8443 上的连接器用于组件间请求(ShareUI > 存储库、Solr 跟踪器 > 存储库)。如果您不知道自己在做什么,请不要修改这些连接器/密钥库。 相反:您可以将 8080/8443 的连接器配置为在本地主机上侦听,以强制通过 Apache 发送任何最终用户请求。