Welcome! Log In Create A New Profile

Advanced

Как использовать переменную upstream_http_x_auth_request_user

January 08, 2020 08:50AM
у меня есть конфигурация nignx v1.17.6 c oauth2_proxy v4.1.0-12-g7663565 авторизация проходит через Azure.

server {

listen 443 ssl;

server_name 127.0.0.1;

ssl_certificate ../nginx-selfsigned.crt;
ssl_certificate_key ../nginx-selfsigned.key;

location /oauth2/ {
proxy_pass http://127.0.0.1:4180;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Auth-Request-Redirect $request_uri;
}

location = /oauth2/auth {
proxy_pass http://127.0.0.1:4180;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
# nginx auth_request includes headers but not body
proxy_set_header Content-Length "";
proxy_pass_request_body off;
}

location / {
auth_request /oauth2/auth;
error_page 401 = /oauth2/sign_in;

auth_request_set $user $upstream_http_x_auth_request_user;
auth_request_set $email $upstream_http_x_auth_request_email;
proxy_set_header X-User $user;
proxy_set_header X-Email $email;
auth_request_set $auth_cookie $upstream_http_set_cookie;
add_header Set-Cookie $auth_cookie;

auth_request_set $auth_cookie_name_upstream_1 $upstream_cookie_auth_cookie_name_1;

add_header X-Debug "$user";
add_header X-Debug2 "$email";

set $username ocadmin;

proxy_pass http://127.0.0.1:5601;

proxy_set_header Authorization "Basic secret:secret";


if ($user = "test@mail.ru") {
set $username user1;
}

proxy_set_header es-security-runas-user $username;

}

}

переменную user и email в header видно, и если она ровна test@mail.ru, if все равно не выполняется
Кто подскажет в чем может быть проблема?
Subject Author Posted

Как использовать переменную upstream_http_x_auth_request_user

andrei_abc January 08, 2020 08:50AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 76
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready