Welcome! Log In Create A New Profile

Advanced

Re: auth request и conn limit

Maxim Dounin
April 01, 2016 07:04AM
Hello!

On Fri, Apr 01, 2016 at 03:02:01AM -0400, Vans_ wrote:

> Добрый день всем!
>
> Можно ли заставить работать одновременно conn_limit и auth_request
> одновременно?
>
> Желаемая схема такая:
> location /data0002 {
> auth_request /authcheck;
> auth_request_set $error_code $upstream_http_x_error_code;
> auth_request_set $token $upstream_http_x_token;
> limit_conn connections 1;
> limit_conn_status 429;
> error_page 403 =200 /forbiden;
> error_page 429 =200 /to_many_connections;
> proxy_intercept_errors on;
> proxy_pass_request_body off;
> proxy_set_header Content-Length "";
> proxy_pass http://127.0.0.1:8000/data;
> error_page 500 501 502 503 504 404 403 =200 /no_data;
> }
>
> Но смысл в том, что похоже conn_limit отрабатывает до auth_check и $token
> устанавливается после того, как отработает conn_limit.
> Причем, задать $token статически, то conn_limit отрабатывает, но это не
> интересно.....

Так работать не будет, т.к. limit_conn работает до авторизации, а
$token доступен только после.

Извлекайте $token из запроса до авторизации (а в процессе
авторизации, соответственно, подтверждайте право его
использования). Тогда всё будет работать.

--
Maxim Dounin
http://nginx.org/

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

Re: auth request и conn limit

Maxim Dounin April 01, 2016 07:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 171
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