问题
I am trying to setup custom 403 and 404 error pages on Apache.
Server config is as follows:
Server version: Apache/2.4.29 (Ubuntu)
Server built: 2019-04-03T13:22:37
Ubuntu 18.04.2 LTS
I use Apache for AJP reverse proxy, as below:
ProxyVia On
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /app ajp://localhost:8009/share
ProxyPassReverse /app ajp://localhost:8009/share
My ErrorDocument code is as below:
ErrorDocument 404 /cah-404.html
ErrorDocument 403 /cah-403.html
Now if I go via browser to the above app, like "https://server.xyz/app", I get a message like the below:
Forbidden
You don't have permission to access /app/ on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.4.29 (Ubuntu) Server at server.xyz Port 443
My custom error pages are at /var/www/html Permission on those pages is 444
Any ideas why this error is happening? I am trying to access the page from an ISP that is not authorised. So it is fine that Forbidden is showing - but it should show the custom forbidden page.
回答1:
I have resolved this using: https://serverfault.com/questions/266924/apache-reverse-proxy-error-page-when-proxied-server-is-down
The key part of the answer is "You should use a URL to point to your ErrorDocument otherwise if you use a filesystem reference you will get an additional 503 whilst trying to find it."
So now, my errordocument directives look like:
ErrorDocument 404 http://server.xyz/cah-404.html
ErrorDocument 403 http://server.xyz/cah-403.html
来源:https://stackoverflow.com/questions/56966239/custom-error-page-not-showing-with-using-ajp-proxy-with-apache