Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Smiffy's avatar

Basic Auth Exception with Nginx

I want to protect my staging site with basic auth which I've managed to do via the Forge CP. I have one URl which needs to be unprotected as we're testing a Stripe integration and want to open that up. I have middleware which will restrict the IP addresses that can operate on that endpoint.

According to sources online, the way to unprotect a uri from basic auth is:

location /unprotected-uri {
        auth_basic off;
}

Which I have added to the end of /etc/nginx/forge-conf/staging.mysite.com/server/protected_site-21104.conf. So full file reads as:

auth_basic "Restricted Area";
auth_basic_user_file /etc/nginx/forge-conf/staging.mysite.com/server/.htpasswd-21104;

location /unprotected-uri {
        auth_basic off;
}

But when calling this, it still results in "Authorization Required".

Any suggestions?

0 likes
0 replies

Please or to participate in this conversation.