Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using Apache 2.2 with mod-proxy and I have configured it with several ProxyPass statements to proxy from remote URL to local URL. I need to have custom error documents returned from Apache for these proxied URLs so I set "ProxyErrorOverride On" in my mod-proxy configuration along with some ErrorDocument directives (with local URL path) to return custom error pages for a few HTTP status codes of interest. However, when a status code is returned for which I have NOT created an ErrorDocument directive for, Apache replaces the response body with a default error page instead of leaving the original response body intact. This won't work with the application. So I really have 2 questions:

1) Is it possible to configure Apache to leave the original response body intact for a particular status code if I don't have an ErrorDocument override defined for it?

2) Is it possible to have the ProxyErrorOverride directive only apply to some of the URLs in my ProxyPass statements?

share|improve this question
2  
Afraid the answer is: No and No. If the directive could be limited to a location, directory, or set of URL's, then there would be something in the "Context" section, of the man page: httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxyerroroverride –  arober11 Nov 15 '12 at 18:57

2 Answers 2

up vote 1 down vote accepted

As arober11 pointed out in the comment above:

Afraid the answer is: No and No. If the directive could be limited to a location, directory, or set of URL's, then there would be something in the "Context" section, of the man page: httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxyerroroverride

on the other hand: you can always add it to mod_proxy.c yourself.

share|improve this answer

For question 2: Definitely doable. Using internal redirects to either new host or port this is possible. Brief outline using hosts (add noErrorOverrideUrl,doErrorOverrideUrl in DNS or /etc/hosts of apache-machine):

NameVirtualHost *:80
<VirtualHost *:80>
   RewriteEngine On
   RewriteRule ^(/noErrorOverrideUrl/.*) http://noErrorOverrideUrl$1 [L,P]
   RewriteRule ^(/doErrorOverrideUrl/.*) http://doErrorOverrideUrl$1 [L,P]          
</VirtualHost>

<VirtualHost *:80>
   ServerName noErrorOverrideUrl
   ProxyErrorOverride Off
   ProxyPass ...
   ...
</VirtualHost>

<VirtualHost *:80>
   ServerName doErrorOverrideUrl
   ProxyErrorOverride On
   ProxyPass ...
   ...
</VirtualHost>

Brief outline using ports:

Listen 80
Listen 81
Listen 82
<VirtualHost *:80>
   RewriteEngine On
   RewriteRule ^(/noErrorOverrideUrl/.*) http://server:81$1 [L,P]
   RewriteRule ^(/doErrorOverrideUrl/.*) http://server:82$1 [L,P]
</VirtualHost>

<VirtualHost *:81>
   ProxyErrorOverride Off
   ProxyPass ...
   ...
</VirtualHost>

<VirtualHost *:82>
   ProxyErrorOverride On
   ProxyPass ...
   ...
</VirtualHost>
share|improve this answer

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.