0

Trying to use Nginx to password protect

mysite.com/admin

the thing is here that I'm using a web framework, and /admin is just another configured route in the system NOT a real directory

when I configured the site with:

location /admin {
    auth_basic "Administrator Login";
    auth_basic_user_file /usr/share/nginx/html/mysite.com/.htpasswd;
}

and generated the htpasswd file, when I try to access the /admin, I get presented with login prompt, and it works great. But now any time I access the path, I get a 404 Not Found from Nginx itself

Anything I should do differently?

Thanks!

RedactedProfile
  • 2,748
  • 6
  • 32
  • 51

1 Answers1

1

and /admin is just another configured route

You can put configuration for that route in block like this

location /admin {
    auth_basic "Administrator Login";
    auth_basic_user_file /usr/share/nginx/html/mysite.com/.htpasswd;
    .
    <your route configuration>
    .
}
Harshad Yeola
  • 1,060
  • 9
  • 10