Plone / Apache自定义错误页面

时间:2015-04-14 10:18:13

标签: apache plone httpd.conf

我正在尝试为404和500错误生成自定义错误页面。 I've tried adding ErrorDocument 404 "My custom error message" to httpd.conf但它没有任何效果。谁能看到我做错了什么?

ServerRoot "/etc/httpd"

Listen 80

NameVirtualHost *:80

Include conf.modules.d/*.conf

User apache
Group apache

ServerAdmin root@localhost

<Directory />
    AllowOverride All
    Require all denied
    ErrorDocument 500 "testing custom 500 error"
    ErrorDocument 404 http://www.google.com
    ErrorDocument 503 http://www.google.com
</Directory>

DocumentRoot "/var/www/"

<Directory "/var/www">
    AllowOverride All
    Options Indexes FollowSymLinks
    ErrorDocument 500 "testing custom 500 error"
    ErrorDocument 404 http://www.google.com
    ErrorDocument 503 http://www.google.com
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    ErrorDocument 500 "testing custom 500 error"
    ErrorDocument 404 http://www.google.com
    ErrorDocument 503 http://www.google.com
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride All
    Options None
    Require all granted
    ErrorDocument 500 "testing custom 500 error"
    ErrorDocument 404 http://www.google.com
    ErrorDocument 503 http://www.google.com
</Directory>

<IfModule mime_module>
    TypesConfig /etc/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>

EnableSendfile on

<VirtualHost *:80>
    ServerName ***
    RewriteEngine on
    RewriteRule   ***
    RewriteRule   ***
    ProxyPreserveHost on
    ProxyPass /showemails ***
    ProxyPassReverse /showemails ***
    ProxyPreserveHost On
    ProxyPass / ***
    ProxyPassReverse / ***
    ProxyPassReverseCookiePath /security /
    AllowOverride All
    ErrorDocument 500 /core/error
    ErrorDocument 404 /core/error
    ErrorDocument 503 http://www.google.com
</VirtualHost>

IncludeOptional conf.d/*.conf

2 个答案:

答案 0 :(得分:1)

我认为您缺少ProxyErrorOverride On directive

  

描述:覆盖代理内容的错误页面

     

此   指令对于您希望拥有的反向代理设置非常有用   最终用户看到的错误页面上的常见外观。 [...]

     

该指令不影响信息处理(1xx),   正常成功(2xx)或重定向(3xx)响应。

答案 1 :(得分:0)

Eamonn,我有一个解决方案: - )

# /etc/apache2/sites-available/sitename
<VirtualHost *:80>

        ServerAdmin plone@localhost
        ServerName sitename.domain

        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access-sitename.log combined
        ErrorLog ${APACHE_LOG_DIR}/error-sitename.log

        # Custom errors for the proxied zope server
        ProxyErrorOverride On
        ErrorDocument 500 'Sorry, our script crashed'
        ErrorDocument 404 'http://google.com/404'

    <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/%{SERVER_NAME}:80/sitename/VirtualHostRoot/$1 [L,P]
    </IfModule>

</VirtualHost>