commit f769d3e24676b1cec9f950b985a55f3dff36aa2e
parent 299f2c26a867bdb5c05fdf107570dfa776531d7e
Author: Leah (ctucx) <leah@ctu.cx>
Date: Fri, 5 Mar 2021 21:53:27 +0100
parent 299f2c26a867bdb5c05fdf107570dfa776531d7e
Author: Leah (ctucx) <leah@ctu.cx>
Date: Fri, 5 Mar 2021 21:53:27 +0100
update nginx-config: allow direct file access but require basic-auth for directory listings
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/nginx.conf b/nginx.conf @@ -36,16 +36,11 @@ server { root /var/lib/websites/music.ctu.cx; - location / { + location ~ ^(.*/)$ { autoindex on; autoindex_exact_size off; - - set $basic_auth off; - if ($http_user_agent != 'libmpv') { - set $basic_auth 'Auth required'; - } - auth_basic $basic_auth; + auth_basic 'Auth required'; auth_basic_user_file /etc/nginx/passwd/music.ctu.cx; autoindex_format xml; @@ -54,13 +49,6 @@ server { } location ~(.*)playlist.m3u$ { - set $basic_auth off; - if ($http_user_agent != 'libmpv') { - set $basic_auth 'Auth required'; - } - auth_basic $basic_auth; - auth_basic_user_file /etc/nginx/passwd/music.ctu.cx; - set $url http://127.0.0.1:81$1; proxy_pass $url; proxy_set_header Domain $scheme://$host; @@ -69,13 +57,6 @@ server { } location /assets/ { - set $basic_auth off; - if ($http_user_agent != 'libmpv') { - set $basic_auth 'Auth required'; - } - auth_basic $basic_auth; - auth_basic_user_file /etc/nginx/passwd/music.ctu.cx; - alias /var/lib/websites/webmusic-assets/; } }