CentOS 7 Web 服务器有 tomcat 在 apache httpd 反向代理后面提供 war 文件。当 WAR 文件都是服务器端代码时,这非常有效。但是,当客户端代码(在本例中为 AngularJS)与服务器端代码一起包含在 war 文件中时,在domain3.com
Web 浏览器中键入时,apache httpd 2.4 会针对应用程序中核心 html 文件的每个依赖项抛出以下代理错误:
[proxy:error] AH00898: DNS lookup failure for: resources returned by /res$
为了确认这是一个apache错误而不是tomcat错误,我在firewalld中打开了该应用程序的8084端口,然后加载domain3.com:8084
以发现该应用程序运行良好,包括其客户端、AngularJS、代码。
需要进行哪些配置更改才能使 apache httpd 2.4 能够在向domain3.com
Web 浏览器中输入请求时为战争中包含的客户端应用程序提供包含内容?
此类domain3.com
事务的完整 httpd 日志如下:
[Tue Nov 03 14:31:57.662516 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013resources returned by /res$
[Tue Nov 03 14:31:57.747345 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013resources returned by /res$
[Tue Nov 03 14:31:57.752815 2015] [proxy:error] [pid 9294] [client client.ip.addr:57370] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:57.757663 2015] [proxy:error] [pid 11936] [client client.ip.addr:57372] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/an$
[Tue Nov 03 14:31:57.758121 2015] [proxy:error] [pid 4325] [client client.ip.addr:57371] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:57.758509 2015] [proxy:error] [pid 23006] [client client.ip.addr:57373] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/an$
[Tue Nov 03 14:31:57.762749 2015] [proxy:error] [pid 9325] [client client.ip.addr:57374] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:57.829953 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:57.846174 2015] [proxy:error] [pid 9294] [client client.ip.addr:57370] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:57.851022 2015] [proxy:error] [pid 4325] [client client.ip.addr:57371] AH00898: DNS lookup failure for: server.ip.addr:8013somecontroller.js returned$
[Tue Nov 03 14:31:58.049885 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.207199 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.320704 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.428737 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.523564 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.611546 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.708439 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013somecontroller.js returned$
同一domain3.com
事务的 Tomcat 日志仅显示一个成功的 GET 请求:
client.ip.addr - - [03/Nov/2015:14:31:57 -0500] "GET / HTTP/1.1" 200 2944
客户端将这些视为依赖项的 502 错误,但不是 502 错误index.html
,这是唯一正确提供服务的资源。
的相关部分/etc/httpd/conf.d/virtualhosts.conf
是:
<VirtualHost www.domain3.com:80>
ServerName www.domain3.com
ServerAlias domain3.com
ErrorLog /var/log/httpd/domain3_com_error.log
CustomLog /var/log/httpd/domain3_com_requests.log combined
ProxyPass / ajp://server.ip.addr:8013
ProxyPassReverse / ajp://server.ip.addr:8013
</VirtualHost>
那么,为了满足httpd
应用程序客户端部分中包含文件的请求,我需要更改哪些内容domain3.com
?
答案1
将缺少的尾部斜杠添加到您的ProxyPass
andProxyPassReverse
指令中:
ProxyPass / ajp://server.ip.addr:8013/
ProxyPassReverse / ajp://server.ip.addr:8013/