2011-01-12 160 views
5

我有apache2和tomcat6(沒有從apt庫中安裝,手動下載並安裝)在端口80上運行,mod_jk設置。訪問jsp servlet頁面,將瀏覽器指向http://myapp.mydomain.com/(虛擬主機在tomcat(server.xml)和apache中完成)。在部署期間,當tomcat關閉(pkill -9 java或/etc/init.d/tomcat stop)時,我試圖將tomcat的錯誤頁面503重定向到自定義錯誤頁面。apache tomcat 503自定義錯誤頁面

我的Apache的文檔根目錄爲/ var/WWW /所以我把下面的條目apache2.conf文件

ErrorDocument 503 maintenance.html和創建在/ var/WWW文件maintenance.html。當我測試停止tomcat時,我將頁面重定向到maintenance.html,但沒有更改url,但實際頁面未顯示,而是在瀏覽器上顯示文件名maintenance.html。任何人可以幫助我正確地配置Apache重定向到正確的maintenance.html頁面,當tomcat關閉?

回答

4

apache documentation

URLs can begin with a slash (/) for local web-paths (relative to the 
DocumentRoot), or be a full URL which the client can resolve. 

我想ErrorDocument 503 /maintenance.html應該工作。

+0

在`/等/ apache2的//000-defaults`文件DocumentRoot的是'在/ var/WWW /`啓用站點,而不是'在/ var/www` 。如果我使用`/ maintenance.html`而不是`maintenance.html`,我會得到相同的`Server Temporarly Unavailable`錯誤頁面。 – user465465 2011-01-12 10:44:34

0

如果您使用Apache與Tomcat連接器,該解決方案比簡單添加和ErrorDocument指令稍微複雜一些。您必須明確告訴Apache不要在/maintenance.html文件的掛接連接器中查找;相反,它需要在本地尋找它。

我貼我的工作解決這個問題here