Report this

What is the reason for this report?

nginx basic HTML authentication on a subfolder

Posted on June 25, 2015

Hello - I am attempting to apply basic HTML authentication to a subfolder on my site. I followed the tutorial - https://www.digitalocean.com/community/tutorials/how-to-set-up-http-authentication-with-nginx-on-ubuntu-12-10 and am able to:

  1. Generate a .htpasswd file in the subfolder, and
  2. Add the following lines to a location block in the nginx.conf as follows:
  location / {
    try_files $uri/index.html $uri.html $uri @app;
    auth_basic "Restricted";
    auth_basic_user_file /var/www/pepperslice/current/public/ps/jeffaltman/.htpasswd;
}

However, my results are as follows:

  1. There is no prompt for credentials
  2. The entire site and specified subfolder can longer find various css and js files

Any ideas for how I can 1) password protect the subfolder pepperslice.com/ps/jeffaltman and 2) why the paths are lost?

I would also like to use different username and password combinations for other subfolders.

Thanks,

Jeff

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.