小编Loo*_*ing的帖子

NGINX auth_request 和 302 响应状态 = 500 无效 URL 前缀

我正在尝试使用 OAuth2 服务器(授权代码流)对 NGINX 请求进行身份验证,该服务器会将客户端重定向到登录页面。是否可以使用 auth_request 指令来实现这一点?这是我的 nginx.conf:

server {
    listen ${NGINX_PORT};

    proxy_send_timeout    600;
    proxy_connect_timeout    600;
    proxy_read_timeout    600;
    send_timeout        600;
    client_max_body_size 100m;
    absolute_redirect off;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log warn;

    location / {
        auth_request /authn;
        gzip_static on;
        index   index.html;
        root /usr/share/nginx/html;
        try_files $uri $uri/ @index;
    }

    location @index {
        root /usr/share/nginx/html;
        add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
        expires 0;
        try_files /index.html =404;
    }

    location /api {
        set $target http://gateway:8030/api;
        proxy_pass http://gateway:8030/api;
    }
    location /authn {
        set $target http://gateway:8030/authn;
        proxy_pass http://gateway:8030/authn; …
Run Code Online (Sandbox Code Playgroud)

nginx proxy authentication redirection

5
推荐指数
0
解决办法
1763
查看次数

标签 统计

authentication ×1

nginx ×1

proxy ×1

redirection ×1