Ssl
如何使用 httpd (https/ssl) 作為 tomcat 的代理伺服器
我已經在我的伺服器上安裝了 httpd 和 tomcat,但不知何故我無法連接它們。
<VirtualHost *:80> ServerName www.harshrathod.dev ServerAlias harshrathod.dev ServerAdmin ****************** DocumentRoot /var/www/html DirectoryIndex index.html RewriteEngine on RewriteCond %{SERVER_NAME} =www.harshrathod.dev [OR] RewriteCond %{SERVER_NAME} =harshrathod.dev RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] ProxyRequests off ProxyPass /projects/legend ajp://localhost:8009/legend ProxyPassReverse /projects/legend ajp://localhost:8009/legend </VirtualHost>
訪問harhrathod.dev 上的圖例頁面顯示錯誤,而不是響應“../webapps/legend”中的index.jsp 頁面。兩台伺服器都已啟動並正在執行。HTTPD 在 localhost:8080 上偵聽 80 和 tomcat
我需要將其粘貼到:
ProxyRequests off ProxyPass /projects/legend ajp://localhost:8009/legend ProxyPassReverse /projects/legend ajp://localhost:8009/legend
在 httpd-le-ssl.conf 中?
error_log 上有這些與代理相關的錯誤
[Sun Mar 29 17:13:28.909192 2020] [proxy:error] [pid 6690] (70007)The timeout specified has expired: AH00957: AJP: attempt to connect to 120.0.0.1:8009 (120.0.0.1) failed [Sun Mar 29 17:13:28.909285 2020] [proxy_ajp:error] [pid 6690] [client 27.56.193.67:10405] AH00896: failed to make connection to backend: 120.0.0.1, referer: https://harshrathod.dev/ [Sun Mar 29 17:18:19.513513 2020] [proxy:error] [pid 6659] (70007)The timeout specified has expired: AH00957: AJP: attempt to connect to 120.0.0.1:8009 (120.0.0.1) failed [Sun Mar 29 17:18:19.513582 2020] [proxy_ajp:error] [pid 6659] [client 103.125.234.198:57195] AH00896: failed to make connection to backend: 120.0.0.1, referer: https://harshrathod.dev/
您
<VirtualHost *:80>
設置為將所有內容重定向到埠443
(至少對於harshrathod.dev
andwww.harshrathod.dev
域),因此該ProxyPass
指令將永遠不會被執行。正如您在問題中建議的那樣,您應該將
ProxyPass
和相關指令移至您的<VirtualHost *:443>
.另請注意,此配置中未使用Tomcat 的
HTTP/1.1
<Connector>
on 埠。8080
您改用AJP/1.3
<Connector>
on 埠8009
,這是一個更快的協議。如果您想使用(較慢)HTTP/1.1
<Connector>
使用:ProxyPass /projects/legend http://localhost:8080/legend ProxyPassReverse /projects/legend http://localhost:8080/legend