Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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>
share|improve this question

1 Answer 1

up vote 4 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>
share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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