Opened 10 years ago

Last modified 7 years ago

#633 new defect

limit_except causes 404

Reported by: Tom Vaughan Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.7.x
Keywords: Cc:
uname -a: Linux vagrant-ubuntu-trusty-64 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.4.6 (Ubuntu)
built by gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.4.6/debian/modules/nginx-auth-pam --add-module=/build/buildd/nginx-1.4.6/debian/modules/nginx-dav-ext-module --add-module=/build/buildd/nginx-1.4.6/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.4.6/debian/modules/nginx-upstream-fair --add-module=/build/buildd/nginx-1.4.6/debian/modules/ngx_http_substitutions_filter_module

Description

This does not work:

    location / {
        limit_except OPTIONS {
            auth_basic "Access is restricted.";
            auth_basic_user_file /srv/app/www/htpasswd;
        }
        try_files $uri $uri/ @app;
    }

    location @app {
        include uwsgi_params;
        uwsgi_pass unix:///run/uwsgi/app/app/socket;
    }

$ curl -ski https://localhost -X OPTIONS
HTTP/1.1 200 OK

$ curl -ski -u username:password https://localhost -X GET
HTTP/1.1 404 Not Found

error.log:
[error] 23859#0: *25 "/var/www/site/index.html" is not found (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"

But this does work:

    location / {
        try_files $uri $uri/ @app;
    }

    location @app {
        limit_except OPTIONS {
            auth_basic "Access is restricted.";
            auth_basic_user_file /srv/app/www/htpasswd;
        }
        include uwsgi_params;
        uwsgi_pass unix:///run/uwsgi/app/app/socket;
    }

Previously I had:

    auth_basic "Access is restricted.";
    auth_basic_user_file /srv/app/www/htpasswd;

    location / {
        try_files $uri $uri/ @app;
    }

    location @app {
        include uwsgi_params;
        uwsgi_pass unix:///run/uwsgi/app/app/socket;
    }

This works too with the exception that OPTIONS requires a username and password.

Change History (4)

comment:1 by Tom Vaughan, 10 years ago

Please note that the version that works leaves static content unprotected. This is not the behavior I want. Thanks.

comment:2 by dryvenn@…, 9 years ago

+1

comment:3 by Maxim Dounin, 8 years ago

This is basically identical to the same problem with if, see #86.

comment:4 by Maxim Dounin, 7 years ago

See also #1383.

Note: See TracTickets for help on using tickets.