Welcome! Log In Create A New Profile

Advanced

Re: duplicating or forking incoming requests

Maxim Dounin
July 12, 2013 04:06PM
Hello!

On Fri, Jul 12, 2013 at 12:47:02PM -0700, Gary Foster wrote:

[...]

> Here's the configuration snippets I'm currently using:
>
> location = /events {
> access_log events_access.log events_format;
> expires 1s;
> try_files @proxy @proxy;
> # try_files @proxy /empty.html;
> # try_files @proxy =200;

You are trying to use try_files incorrectly. Please read docs at
http://nginx.org/r/try_files.

> }
>
> location @proxy {
> proxy_pass http://127.0.0.1:8887;
> proxy_intercept_errors on;
> access_log events_access.log events_format;
> error_page 502 =200 /empty.html;
> proxy_set_header X-Real-IP $remote_addr;
> }
>
> Basically, what I want is that if it logs every incoming request
> normally. If it can forward the request to the upstream proxy,
> it does so after logging it, and if it can't, it simply logs it
> and returns a 200.
>
> Is this possible and if so how?

I would recommend something like this:

location = /events {
access_log events_access.log events_format;
error_page 502 504 = /empty;
proxy_pass ...;
}

location = /empty {
access_log events_access.log events_format;
return 200 "";
}

Note the above configuration snippet doesn't try to intercept
errors returned by upstream servers, but only handles cases when
nginx can't reach them and/or an invalid response is returned. If
upstream servers are expected to return various errors,
proxy_intercept_errors should be used, as well as additional codes
in error_page.

--
Maxim Dounin
http://nginx.org/en/donation.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

duplicating or forking incoming requests

Gary Foster July 12, 2013 03:48PM

Re: duplicating or forking incoming requests

Maxim Dounin July 12, 2013 04:06PM

Re: duplicating or forking incoming requests

Gary Foster July 12, 2013 05:02PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 140
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready