nginx:basic_authentication
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
nginx:basic_authentication [2016/10/13 23:33] – created peter | nginx:basic_authentication [2019/12/01 10:19] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== NginX - Basic Authentication ====== | ||
- | |||
- | This is the Nginx equivalent to basic HTTP authentication on Apache with .htaccess /.htpasswd. | ||
- | |||
- | ===== Creating the Password File ===== | ||
- | |||
- | We need a password file where users that should be able to log in are listed with their passwords (in encrypted form). | ||
- | |||
- | ===== Using Apache' | ||
- | |||
- | If you want to use Apache' | ||
- | |||
- | <code bash> | ||
- | which htpasswd | ||
- | </ | ||
- | |||
- | Will return something like this is the htpassed command exists on the system. | ||
- | |||
- | < | ||
- | / | ||
- | </ | ||
- | |||
- | |||
- | If the command returns without any output, htpasswd does not exist on your system, and you must install it. On Debian/ | ||
- | |||
- | <code bash> | ||
- | apt-get -y install apache2-utils | ||
- | </ | ||
- | |||
- | |||
- | I want to create the password file / | ||
- | |||
- | <code bash> | ||
- | htpasswd -c / | ||
- | </ | ||
- | |||
- | You will be asked for a password for the user john. Please note that the -c switch makes that the file is created from scratch; if it didn't exist before, it will be created; if it existed before, it will be overwritten with a new one, and all users from the old file will be lost! Therefore, if you want to add another user without deleting all existing users, use the htpasswd command without the -c switch: | ||
- | |||
- | <code bash> | ||
- | htpasswd / | ||
- | </ | ||
- | |||
- | The last command adds the user jack to / | ||
- | |||
nginx/basic_authentication.1476401639.txt.gz · Last modified: 2020/07/15 09:30 (external edit)