1

I want to access the folder /folder/subfolder/ in the webservers root (/var/www/dl.somewebsite.com/files/) with a password the rest should be public accessible. Using the script below I get a 403 Forbidden error when using the right credentials. What am I missing out here?

 server {
        listen 80;
        server_name dl.somewebsite.com;

            access_log /var/www/nginx-logs/dl.somewebsite.com combined;

        root /var/www/dl.somewebsite.com/files/;

        location / {
            autoindex on;
        }

        location ^~ /folder/subfolder/ {
             auth_basic  "Restricted";
             auth_basic_user_file /etc/nginx/somefolder/dl.somewebsite.com/.htpasswd;
        }
    }
5
  • What do you expect instead of getting 403 Forbidden?
    – gxx
    Nov 8, 2015 at 15:04
  • The page that was restricted ;)
    – Flatron
    Nov 8, 2015 at 18:01
  • And what does the access / error log say, about the request?
    – gxx
    Nov 8, 2015 at 18:24
  • How did you encode/encrypt the password? Or how exactly did you generate the .htpasswd file?
    – JayMcTee
    Nov 8, 2015 at 20:38
  • htpasswd -c someusername from apache2 utilities
    – Flatron
    Nov 10, 2015 at 7:08

1 Answer 1

0

Ensure that the /etc/nginx/somefolder/dl.somewebsite.com/.htpasswd that you configured is actually there.

If that doesn't solve, you can figure out the problem checking the access.log or error.log.
Use docker logs -f CONTAINER, or directly access the webserver via SSH and run tail -f /var/log/nginx/error.log (exact location may differ).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .