為什麼 apache 會出現 DNS 查找失敗?

為什麼 apache 會出現 DNS 查找失敗?

CentOS 7 Web 伺服器有 tomcat 在 apache httpd 反向代理後面提供 war 檔。當 WAR 檔案都是伺服器端程式碼時,這非常有效。但是,當客戶端程式碼(在本例中為 AngularJS)與伺服器端程式碼一起包含在 war 檔案中時,在domain3.comWeb 瀏覽器中鍵入時,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.comWeb 瀏覽器中輸入請求時為戰爭中包含的客戶端應用程式提供包含內容?

此類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

將缺少的尾部斜線添加到您的ProxyPassandProxyPassReverse指令中:

ProxyPass / ajp://server.ip.addr:8013/
ProxyPassReverse / ajp://server.ip.addr:8013/

相關內容