Restricting Access with HTTP Basic Authentication
by John Vincent
Posted on August 12, 2019
This document discusses configuring Nginx to restrict Access with HTTP Basic Authentication www.johnvincent.io
website.
For extensive discussions regarding www.johnvincent.io
, please see Overview of johnvincent.io website
Configuring Nginx to implement HTTP Basic Authentication
The goal is to password protect certain folders and pages.
Excellent references
Install Apache Utilities
sudo apt-get update
sudo apt-get install apache2-utils
Create Password File
Add a username
cd
cd tmp
sudo htpasswd -c /etc/nginx/.htpasswd jv
Add encrypted password
sudo sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd"
Configuring Nginx
cd /etc/nginx/sites-available/https
sudo vi johnvincent.io
Add
location /interview {
auth_basic “Private Area”;
auth_basic_user_file /etc/nginx/.htpasswd;
}
Restart Nginx
nginx-restart
Remove from Site Map
Password protected pages need to be removed from the site map to prevent issues with Google Search. For details, see Google Coverage Issues
Problems
If get 401 Authorization Required
and no sign in form
- Try another browser
- Open Devtools and re-try
Even then, may be necessary to refresh and re-try.
Jekyll
Johnvincent.io
- Backup Website from Digital Ocean
- Building and deploying MyTunes to johnvincent.io
- Building and deploying React Github Helper App to johnvincent.io
- Configure HTTP Nginx
- Configure HTTPS Nginx
- Configure PM2
- Configuring Google Domains
- Create SSL Certificates
- Create Ubuntu Droplet at Digital Ocean
- Deploy to Droplet
- Google Webmaster Tools
- Install Ubuntu Nginx
- Maintaining Ubuntu Droplet
- Overview of Deployment of a Node API Server
- Overview of johnvincent.io
- Overview of React Gomoku
- Overview of React Hangman
- Overview of React Lights Out
- Overview of React Yahtzee
- Restricting Access with HTTP Basic Authentication
- Update SSL Certificates