Apache ProxyPass 出現503 Service Temporarily Unavailable 錯誤的解決方案

 

今天在Redhat5 Linux上配置Apache和Tomcat整合,希望將Jsp頁面的地址轉發到tomcat的地址上去。
如真實的Jsp地址爲 http://127.0.0.1:8080/jsp/
希望通過訪問 http://127.0.0.1/jsp/ 也可以訪問到。
於是在Apache中配置ProxyPass :
ProxyPass /jsp http://localhost:8080/jsp

但發現當訪問的時候發現不可訪問,出現503錯誤:

Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache Server at localhost Port 80
 

查看apache日誌/var/log/httpd/error_log:

[Wed Aug 10 21:02:27 2011] [error] (13)Permission denied: proxy: HTTP: attempt to connect to 10.140.0.109:7080 (127.0.0.1) failed
[Wed Aug 10 21:02:27 2011] [error] ap_proxy_connect_backend disabling worker for (10.140.0.109)
[Wed Aug 10 20:30:51 2011] [error] proxy: HTTP: disabled connection for (127.0.0.1)
 

 

日誌/var/log/httpd/access_log:

127.0.0.1- - [10/Aug/2011:21:02:27 -0400] "GET /jsp/ HTTP/1.0" 503 401 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; CIBA; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
 

經過查資料和分析懷疑是SELinux的原因,於是查看果然是:

[root@ logs]# /usr/sbin/getsebool -a |grep httpd_can_network_connect
httpd_can_network_connect --> off
 

 

於是嘗試解決方案:
我們需要將httpd_can_network_connect設置爲on:

 

[root@ logs]# /usr/sbin/setsebool -P httpd_can_network_connect=1
[root@ logs]# /usr/sbin/getsebool -a |grep httpd_can_network_connect
httpd_can_network_connect --> on
 

 

重新訪問,頁面果然可以訪問了。
另外直接關掉SELinux也是可以解決這個問題的:
修改/etc/selinux/config 然後重啓:

SELINUX=disabled
 

或者實時生效的方式:

 

[root@ var]# /usr/sbin/setenforce 0
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章