Nginx - Exclude php files from htpasswd on a specified directory -
my nginx directives:
location / { index index.html index.php; auth_basic "members only"; auth_basic_user_file /var/www/clients/client1/web1/web/.htpasswd_stats; } location ~ \.php$ { allow 1.2.3.4; allow 127.0.0.1; deny all; auth_basic "members only"; auth_basic_user_file /var/www/clients/client1/web1/web/.htpasswd_stats;
}
location /dir/ { auth_basic off;
}
i use 'auth_basic off' option exclude 'dir' directory htpasswd check.
when try acces http://domain/dir/ see files except php files because previous directive asking me authentication.
on apache use 'satisfy any' option if use option on nginx, doesn't work me or put on incorrect site.
my goal when access http://domain/dir/ there no authentication file.
thanks!!
this because have separate auth_basic
.php
files.
to save .php
files inside /dir/
add location block , set rules inside block according usecase
location ~ /dir/(.+)\.php$ { allow 1.2.3.4; allow 127.0.0.1; deny all; auth_basic off; }
Comments
Post a Comment