Forum Sondria46®   →   Sondria46_Blog   →   Blog_Articles   →   Using Password Protection in Nginx

Using Password Protection in Nginx

Started by admin Nov 06th, 2024 at 10:30
admin
Admin
Posts: 95
Nov 06th, 2024 at 10:30

If you're using Nginx, you can set up basic authentication using a similar approach:

  1. Generate the password file:

printf "username:$(openssl passwd -crypt password)\n" >> /etc/nginx/.htpasswd

           Replace username and password with your credentials 

 

      2.  Edit your Nginx configuration file to include the authentication for the specific URL:

location /protected-url/ {
    auth_basic "Restricted Content";
    auth_basic_user_file /etc/nginx/.htpasswd;
}

            Replace /protected-url/ with the specific path you want to protect.

 

      3.  Reload Nginx:

sudo service nginx reload

 

      4.  Test the URL to verify the password protection is in place.

 

 

« Last Edit: Nov 06th, 2024 at 10:30 by admin »


Home   •   FAQ   •   Support   •   Terms of Service   •   Privacy   •   News   •   Forum
Copyright © 2024 Sondria46®. All Rights Reserved.
Powered by EvolutionScript Version 6.6