A
A
Alexey2019-04-19 15:18:33
Nginx
Alexey, 2019-04-19 15:18:33

How to properly configure Basic HTTP authorization for Nginx?

You need to close the site.ru/folder/ directory for viewing Added location ^~ /folder/
to Nginx settings { auth_basic "Restricted Area"; auth_basic_user_file /usr/local/.htpasswd; } Works, ok! Now on pages like site.ru/bla-bla.php there are links to images from the closed folder /folder/img/ When I go to the site.ru/bla-bla.php page, I see a broken link to the image and an authorization request window... How can I fix this so that the pictures are loaded and the window does not fly out because I'm not in /folder/?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Mezhuev, 2019-04-19
@mezhuev

What is the purpose of location "/folder/" given via regular expression?

location /folder/ {
    auth_basic "Restricted Area";
    auth_basic_user_file /usr/local/.htpasswd;
}
location /folder/img/ {
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question