Opened 5 years ago

Closed 5 years ago

#1793 closed defect (invalid)

auth_request does not expand variables

Reported by: AnrDaemon@… Owned by:
Priority: minor Milestone:
Component: nginx-module Version:
Keywords: auth_request Cc:
uname -a: Linux 4262fc806aba 4.15.0-50-generic #54-Ubuntu SMP Mon May 6 18:46:08 UTC 2019 x86_64 Linux
nginx -V: nginx version: nginx/1.17.0
built by gcc 8.2.0 (Alpine 8.2.0)
built with OpenSSL 1.1.1b 26 Feb 2019
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-perl_modules_path=/usr/lib/perl5/vendor_perl --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-Os -fomit-frame-pointer' --with-ld-opt=-Wl,--as-needed

Description

This example configuration doesn't work as desired - backend receives literal request for "/api/v1/documents/$1$is_args$args".

    location ~ ^/uploads/documents/(.+)$ {
        alias /volume/data/documents/$1;
        auth_request /auth/documents/$1$is_args$args;
        auth_request_set $auth_status $upstream_status;
    }

    location ^~ /auth/ {
        internal;
        proxy_pass http://back:8080/api/v1/;
        proxy_pass_request_body off;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header X-Original-Uri $request_uri;
        proxy_set_header Content-Length "";
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

This is highly inconvenient.

Change History (1)

comment:1 by Maxim Dounin, 5 years ago

Resolution: invalid
Status: newclosed

Variables are not supported by the auth_request directive. Note that when a directive supports variables in a particular parameter, this is explicitly documented - see, for example, the auth_request_set directive description: "The value may contain variables..."

Note: See TracTickets for help on using tickets.