Thursday, January 29, 2015

NGINX Basic Authorization

 
 I wanted to quickly restrict access to a web domain running on NGINX. An easy way to do this is:

1. find your configuration file often in a subdirectory of /etc/nginx/ for me the path was /etc/nginx/conf.d/local.conf

2. create a file called .htpasswd in the same (could be elsewhere) directory and follow the instructions here as to what to put in it - don't bother with the .htaccess file.

3. add the following lines to your NGINX configuration file and read about them here - you only add a location to pinpoint restricted areas (without means blanket authorization required):

    auth_basic           "closed site";
    auth_basic_user_file conf/htpasswd;