Contact us on Phone:01-4428599 or enquiries@ecomgolive.ie

password protect directory on nginx

password protect directory on nginx
The XX Intro [long version]
htpasswd -bc /var/www/yourdomain.com/.htpasswd username password
Next edit your site’s configuration file by adding the following lines of code inside the server-block:
location ^~ /directory_to_protect/ {
    auth_basic            "Restricted";
    auth_basic_user_file  /var/www/yourdomain.com/.htpasswd;
/etc/init.d/nginx restart