Mixing limit_except breaks rewrite functionality: workaround request

Sten Gruener sten.gruener at gmail.com
Fri Jun 30 09:29:21 UTC 2023


Dear all,

I trying to mix authentication for POST requests with some
rewrite/proxy_pass logic. This mean that password is required only on
POST/PUT requests.

        location /x/ {
            limit_except GET OPTIONS {
                auth_basic "Write Access";
                auth_basic_user_file /etc/nginx/conf.d/htpasswd_write;
            }
            rewrite ^ $request_uri;
            rewrite ^/x/(.*) $1 break;
            return 400;
            proxy_pass http://server:8081/$uri;
        }

The snipped above is not working to to the bug/feature which is known:
https://trac.nginx.org/nginx/ticket/1383


Could someone please provide guidance of whether it is possible to
implement my goal using the proposed map directive from the ticket
itself?


BR and Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20230630/0be9797f/attachment.htm>


More information about the nginx mailing list