You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Manish Rangari <li...@gmail.com> on 2016/06/22 17:03:39 UTC

[users@httpd] Redirect apache proxy 404 request to specific page

Hello Guys,




down votefavorite
<http://stackoverflow.com/questions/37938692/redirect-apache-proxy-404-request-to-specific-page#>


I am trying to specify a page for 404 request but it is not working. Here
apache is acting as a reverse proxy which forwards the request to tomcat. I
am not using any virtual host configuration. Below is my configuration that
I am using

<LocationMatch "^/(application|app)">
        ErrorDocument 404 /application/abc/def.htm
</LocationMatch>

Apache is also hosting few php pages but /application and /app goes to
tomcat.

Re: [users@httpd] Redirect apache proxy 404 request to specific page

Posted by Luca Toscano <to...@gmail.com>.
2016-06-23 12:12 GMT+02:00 Manish Rangari <li...@gmail.com>:

> Hello Luca,
>
> Thanks for your solution. This pretty much took care of the problem. But I
> noticed that on even 404 error apache is not showing 404 but it is showing
> 200 in access log. Is it correct?
>

This seems definitely wrong :) What status code do you get if you make a
query by yourself using curl/wget/etc.. ? Moreover, what version of httpd
are you running? I'd suggest also to increase LogLevel to trace8 (if
possible or if you have a test environment) to track down what httpd is
doing (https://httpd.apache.org/docs/current/mod/core.html#loglevel).

Luca

Re: [users@httpd] Redirect apache proxy 404 request to specific page

Posted by Manish Rangari <li...@gmail.com>.
Hello Luca,

Thanks for your solution. This pretty much took care of the problem. But I
noticed that on even 404 error apache is not showing 404 but it is showing
200 in access log. Is it correct?
On Jun 23, 2016 2:54 PM, "Luca Toscano" <to...@gmail.com> wrote:

> Hello!
>
> 2016-06-22 19:03 GMT+02:00 Manish Rangari <li...@gmail.com>
> :
>
>> Hello Guys,
>>
>>
>>
>>
>> down votefavorite
>> <http://stackoverflow.com/questions/37938692/redirect-apache-proxy-404-request-to-specific-page#>
>>
>>
>> I am trying to specify a page for 404 request but it is not working. Here
>> apache is acting as a reverse proxy which forwards the request to tomcat. I
>> am not using any virtual host configuration. Below is my configuration that
>> I am using
>>
>> <LocationMatch "^/(application|app)">
>>         ErrorDocument 404 /application/abc/def.htm
>> </LocationMatch>
>>
>> Apache is also hosting few php pages but /application and /app goes to
>> tomcat.
>>
>
> By default mod_proxy does not interfere with the response from the
> backend, passing it directly to the client. If you want to force mod-proxy
> to override error responses (like 40X, 50X) you'd need to set
> ProxyErrorOverride (
> https://httpd.apache.org/docs/current/mod/mod_proxy.html#proxyerroroverride
> ).
>
> Hope that helps!
>
> Luca
>
>
>

Re: [users@httpd] Redirect apache proxy 404 request to specific page

Posted by Luca Toscano <to...@gmail.com>.
Hello!

2016-06-22 19:03 GMT+02:00 Manish Rangari <li...@gmail.com>:

> Hello Guys,
>
>
>
>
> down votefavorite
> <http://stackoverflow.com/questions/37938692/redirect-apache-proxy-404-request-to-specific-page#>
>
>
> I am trying to specify a page for 404 request but it is not working. Here
> apache is acting as a reverse proxy which forwards the request to tomcat. I
> am not using any virtual host configuration. Below is my configuration that
> I am using
>
> <LocationMatch "^/(application|app)">
>         ErrorDocument 404 /application/abc/def.htm
> </LocationMatch>
>
> Apache is also hosting few php pages but /application and /app goes to
> tomcat.
>

By default mod_proxy does not interfere with the response from the backend,
passing it directly to the client. If you want to force mod-proxy to
override error responses (like 40X, 50X) you'd need to set
ProxyErrorOverride (
https://httpd.apache.org/docs/current/mod/mod_proxy.html#proxyerroroverride
).

Hope that helps!

Luca