If you're using Nginx, you can set up basic authentication using a similar approach:
- 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 »