Enable basic auth sitewide and disabling it for subpages?
Posted
by
piquadrat
on Server Fault
See other posts from Server Fault
or by piquadrat
Published on 2011-11-13T20:07:38Z
Indexed on
2012/09/07
3:39 UTC
Read the original article
Hit count: 565
nginx
I have a relatively straight forward config:
upstream appserver-1 {
server unix:/var/www/example.com/app/tmp/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://appserver-1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
auth_basic "Restricted";
auth_basic_user_file /path/to/htpasswd;
}
location /api/ {
auth_basic off;
}
}
The goal is to use basic auth on the whole website, except on the /api/
subtree. While it does work with respect to basic auth, other directives like proxy_pass
are not in effect on /api/
as well.
Is it possible to just disable basic auth while retaining the other directives without copy&pasting everything?
© Server Fault or respective owner