tag (nginx)

archive

setting a default virtual host in nginx Aug
20
1
0

If there are multiple conf files included in the sites-enabled directory you can set the Nginx server to default to a particular site by adding a listen directive:

server {
listen 80 default;
... }

comments

password protect nginx directory/location with htpasswd Jul
12
1
0

In apache you can password protect a directory with an .htaccess file. It's a little different in nginx, although I think it's more elegant.

All you need to do is add the following two entries in the location listing in the server conf settings.

location = / {
auth_basic "Restricted";
auth_basic_user_file /path/to/htpasswd; ...
}

and then run htpasswd in the proper location:

htpasswd -c -b htpasswd <user> <pass>

comments