나는 몇 가지 서비스를 가지고 있으며 그들은 nginx 인스턴스 뒤에 서있다. nginx에서 인증을 처리하기 위해 각 요청을 가로 채서 인증 서비스로 보냅니다. 거기에, 자격 증명이 올바른지, 나는 사용자 관련 정보를 포함하는 쿠키를 설정하고 있습니다.nginx 프록시 인증 요격
요청은 이제 쿠키가 설정된 적절한 서비스로 라우팅되어야합니다.
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
upstream xyz {
server ***;
}
upstream auth {
server ***;
}
server {
listen 8080;
location ~ ^/(abc|xyz)/api(/.*)?$ {
auth_request /auth-proxy;
set $query $2;
proxy_pass http://$1/api$query$is_args$args;
proxy_set_header X-Target $request_uri;
proxy_set_header Host $http_host;
}
location = /auth-proxy {
internal;
proxy_pass http://auth;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Target $request_uri;
proxy_set_header Host $http_host;
proxy_set_header X-CookieName "auth";
proxy_set_header Cookie "auth=$cookie_auth";
proxy_set_header Set-Cookie "auth=$cookie_auth";
proxy_cookie_path/"/; Secure; HttpOnly";
add_header Cookie "auth=$cookie_auth";
add_header Set-Cookie "auth=$cookie_auth";
}
}
내가 수동으로 설정 한 X-대상 헤더의 요청에/인증 프록시를 한 경우는, 응답이 예상대로 쿠키를 포함
여기 내의 nginx의 설정입니다.
원하는 대상에 요청하면 요청이 가로 채고 쿠키를 올바르게 설정하는/auth-proxy에 도달합니다. 그러나 요청이 대상에 도달하면 쿠키가 포함되지 않습니다.
대상 요청을 수행 할 때 nginx가 쿠키를 전달하지 않는다고 가정합니다.
저는 지난 며칠 동안이 문제로 고생했습니다 ... 나는 무엇을 놓치고 있습니까?
감사합니다.