I have an Apache web server in front of another application server, using Proxy Pass. When the request to application returned error 404, I want to show custom error page from the web server not the one that come from application server. I have tried to setup the ErrorDocument 404 on the virtual host, but it doesn't work. How should I do this? Or this is not possible?

<VirtualHost *:80>
  ServerName servername
  DocumentRoot /somepath/
  ProxyPass / http://localhost:8080/someapp/
  ProxyPassReverse / http://localhost:8080/someapp/

  ErrorDocument 404 /error.html
</VirtualHost>
link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

You can avoid proxying for a specific directory by specifying a ! in place of the proxy target. Since it acts on a directory, move error.html into a subdirectory (we'll say errors), and:

<VirtualHost *:80>
  ServerName servername
  DocumentRoot /somepath/
  ProxyPass /errors !
  ProxyPass / http://localhost:8080/someapp/
  ProxyPassReverse / http://localhost:8080/someapp/
  ProxyErrorOverride On
  ErrorDocument 404 /errors/error.html
</VirtualHost>
link|improve this answer
Sorry, maybe the config lack some details, but what I want is to catch the error 404 returned from the proxy pass and show the error.html instead. – satyavirya Aug 17 '11 at 5:33
Thanks, I found the way to override, I can just use the ProxyErrorOverride directive – satyavirya Aug 17 '11 at 8:32
@satyavirya Good catch, I'll add that to the answer for future searchers. – Shane Madden Aug 17 '11 at 15:23
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.