我已经在我的服务器上安装了 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>
访问 harshrathod.dev 上的图例页面会显示错误,而不是使用“../webapps/legend”中的 index.jsp 页面进行响应。两个服务器都已启动并运行。HTTPD 正在 80 上监听,tomcat 正在 localhost:8080 上监听
我是否需要将其粘贴到:
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/
答案1
您的<VirtualHost *:80>
设置为将所有内容重定向到端口443
(至少对于harshrathod.dev
和www.harshrathod.dev
域),因此该ProxyPass
指令永远不会被执行。
正如您在问题中所建议的那样,您应该将ProxyPass
和相关指令移至您的<VirtualHost *:443>
。
还要注意,此配置中不使用Tomcat 的HTTP/1.1
<Connector>
on 端口。您改用on 端口,这是一种更快的协议。如果您想使用(较慢的)协议,请使用:8080
AJP/1.3
<Connector>
8009
HTTP/1.1
<Connector>
ProxyPass /projects/legend http://localhost:8080/legend
ProxyPassReverse /projects/legend http://localhost:8080/legend