Недопустимое количество аргументов в директиве "auth_request_set" в /etc/nginx/sites-enabled/projectconf
Я пытался настроить прокси-сервер Nginx с помощью Oauth2Proxy, но при попытке перезапустить сервер я получаю следующую ошибку.
2024/03/03 08:07:41 [emerg] 370#370: invalid number of arguments in "auth_request_set" directive in /etc/nginx/sites-enabled/someapplication:64
2024/03/03 08:52:44 [warn] 968#968: server name "/var/log/nginx/someapplication_access.log" has suspicious symbols in /etc/nginx/sites-enabled/someapplication:5
2024/03/03 08:52:44 [warn] 968#968: server name "/var/log/nginx/someapplication_access.log" has suspicious symbols in /etc/nginx/sites-enabled/someapplication:39
2024/03/03 08:52:44 [warn] 969#969: server name "/var/log/nginx/someapplication_access.log" has suspicious symbols in /etc/nginx/sites-enabled/someapplication:5
2024/03/03 08:52:44 [warn] 969#969: server name "/var/log/nginx/someapplication_access.log" has suspicious symbols in /etc/nginx/sites-enabled/someapplication:39
2024/03/03 09:28:19 [emerg] 2000#2000: unknown "user" variable
Это релиз, который я использую для библиотеки
https://github.com/pusher/oauth2_proxy/releases/download/v5.0.0/oauth2_proxy-v5.0.0.linux-amd64.go1.13.6.tar.gz
Ниже приведена конфигурация nginx на моем сервере
server {
listen 80;
listen [::]:80;
server_name someapplication.com;
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 / {
auth_request /oauth2/auth;
error_page 401 = /oauth2/sign_in;
# pass information via X-User and X-Email headers to backend
# requires running with --set-xauthrequest flag 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;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_header Server;
proxy_connect_timeout 3s;
proxy_read_timeout 10s;
# if you enabled --cookie-refresh, this is needed for it to work with auth_request
auth_request_set $auth_cookie $upstream_http_set_cookie; add_header Set-Cookie $auth_cookie;
proxy_pass http://127.0.0.1:8002;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/someapplication.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/someapplication.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
}
Я нашел проблему, я не присвоил пользовательской переменной значение, поэтому она была неизвестна.
auth_request_set $user $upstream_http_x_auth_request_user;
У меня сработало!