如何解决在ubuntu apache2上添加自定义错误503页面html使用它与mod_jk和虚拟主机重定向到tomcat

use*_*828 4 html ubuntu tomcat apache2 errordocument

我尝试了所有我在apache文档和stackoverflow和博客上发现的其他sugestions.当我将folloowing行添加到任何配置文件,如/etc/apache2/apache2.conf/etc/apache2/conf.d/localized-error-pages/etc/apache2/httpd.conf/etc/apache2/sites-enabled/000-default:

ErrorDocument 503 "This is an error msg"甚至是HTML消息 ErrorDocument 503 "<h1> This is an error message </h1> 或外部URL重定向ErrorDocument 503 http://www.google.com它的工作原理.

但是,当我尝试内部重定向时,ErrorDocument 503 /ERROR_503.html 或者ErrorDocument 503 /error/ERROR_503.html我得到最后一行的默认消息:

此外,尝试使用ErrorDocument处理请求时遇到503 Service Temporarily Unavailable错误.

我试图把html错误页面放在DocumentRoot var/www,at var/www/error.尝试取消注释所有/etc/apache2/conf.d/localized-error-pages将所有错误设置为具有国际化的自定义页面的文件/usr/share/apache2/error.并且由于此文件中的消息与默认值相同,因此该行

此外,尝试使用ErrorDocument处理请求时遇到503 Service Temporarily Unavailable错误.不再显示了.但是,如果我改变线

`ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var`
Run Code Online (Sandbox Code Playgroud)

在本地化错误页面文件中放置到同一页面的新html,错误返回并且页面未显示.如果我编辑文件HTTP_SERVICE_UNAVAILABLE.html.var,浏览器消息也没有任何变化.

更多信息:我正在使用apache2将端口80上的所有请求通过工作端口重定向到端口8089的tomcat.我的配置文件是https://dl.dropboxusercontent.com/u/1105054/apache.zip

Lor*_*ren 6

这花了太长时间(部分由于拼写),但我想我会发布我的整个虚拟主机文件,因为它可能有用.

你需要确保你已经指定了一个DocumentRoot,并且你要ProxyPass /file.html !在主要之前完成ProxyPass /.

<VirtualHost *:443>
    DocumentRoot /var/www/html
    #ProxyPreserveHost On

    <IfModule env_module>
         # Fake SSL if Loadbalancer does SSL-Offload 
         SetEnvIf Front-End-Https "^on$" HTTPS=on
    </IfModule>

    SSLEngine on
    SSLCertificateFile file
    SSLCertificateKeyFile file
    SSLCertificateChainFile file

    ProxyPass /maintenance-message.html !
    ProxyPass /maintance-message_files !
    ProxyPass / "ajp://localhost:8009/"
    ProxyPassReverse / "ajp://localhost:8009/"
    ServerName server.something.com:443
    ErrorDocument 503 /maintenance-message.html
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)


小智 4

就我而言,我刚刚将此ProxyPass行添加到我的虚拟服务器配置中:

ProxyPass /serverError.html !
ErrorDocument 503 /serverError.html
Run Code Online (Sandbox Code Playgroud)

这告诉代理转到 DocumentRoot 并搜索错误页面。

您也可能会发现这个答案很有用:https ://stackoverflow.com/a/13019667