Forum: NGINX "fallback" response code

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Phillip O. (Guest)
on 2009-06-09 11:11
(Received via mailing list)
I'm using a custom perl script in the following way:

location ~ ^/resources {
    error_page 404 @fallback;
}

location @fallback {
    perl MyModule::handler;
}

The fallback works as expected, apart from that it always returns a 404
with content, rather than a 200.

Is there any way to force a 200 when I'm sending content back to the
browser from either the Perl script or from the @fallback block?
andan andan (Guest)
on 2009-06-09 12:20
(Received via mailing list)
2009/6/9 Phillip O. <removed_email_address@domain.invalid>:
> The fallback works as expected, apart from that it always returns a 404 with
> content, rather than a 200.
>
> Is there any way to force a 200 when I'm sending content back to the browser
> from either the Perl script or from the @fallback block?

According with documentation:

Furthermore, it is possible to change the code of answer to another,
for example:
error_page 404 =200 /.empty.gif;

I suppose that this works well with @fallback

BR.
Maxim D. (Guest)
on 2009-06-09 12:22
(Received via mailing list)
Hello!

On Tue, Jun 09, 2009 at 08:05:22AM +0100, Phillip O. wrote:

> I'm using a custom perl script in the following way:
>
> location ~ ^/resources {
>    error_page 404 @fallback;

-    error_page 404 @fallback;
+    error_page 404 = @fallback;

> browser from either the Perl script or from the @fallback block?
You may force 200 by using =200, but it's not really what you
want since this will prevent you from doing 302 redirects and so
on.  The above just uses return code of the fallback handler.

Maxim D.
Igor S. (Guest)
on 2009-06-09 12:24
(Received via mailing list)
On Tue, Jun 09, 2009 at 10:12:43AM +0200, andan andan wrote:

> >
> error_page 404 =200 /.empty.gif;
>
> I suppose that this works well with @fallback

Or

error_page 404 = @fallback;

then it will be used the MyModule::handler's response code.
Systems Maintenance (Guest)
on 2009-06-11 15:30
(Received via mailing list)
Maxim D. wrote:
> -    error_page 404 @fallback;
> +    error_page 404 = @fallback;
>
> You may force 200 by using =200, but it's not really what you
> want since this will prevent you from doing 302 redirects and so
> on.  The above just uses return code of the fallback handler.
>
Perfect. Thanks guys for your responses!
This topic is locked and can not be replied to.