Mobile app version of vmapp.org
Login or Join
Shanna517

: How to set up Nginx directory password authentication? How to set up? Nginx directory password authentication /usr/local/nginx/conf/vhost/xxx.xxx.com.conf site configuration files. I want to in this

@Shanna517

Posted in: #Authentication #Nginx #Password

How to set up? Nginx directory password authentication
/usr/local/nginx/conf/vhost/xxx.xxx.com.conf site configuration files.
I want to in this website xxx.xxx.com/123 folders in password access protection, similar to the apache.But I don't know how to make nginx?
Heard: a folder password protection to set format the location?

server
{
listen 80;
server_name xxx.xxx.com; #server_name end
index index.html index.htm index.php; #index end

set $subdomain '';
root /home/wwwroot/xxx.xxx.com/web$subdomain;
include rewrite/amh.conf; #rewrite end

#error_page
error_page 400 /ErrorPages/400.html;
error_page 403 /ErrorPages/403.html;
error_page 404 /ErrorPages/404.html;
error_page 502 /ErrorPages/502.html;
location ~ /ErrorPages/(400|401|403|404|405|502|503).html$
{
root /home/wwwroot/xxx.xxx.com/web;
}


location ~ .*.php$
{
fastcgi_pass unix:/tmp/php-cgi-xxx.xxx.com.sock;
fastcgi_index index.php;
include fcgi-host.conf;
fastcgi_param DOCUMENT_ROOT /web$subdomain;
fastcgi_param SCRIPT_FILENAME /web$subdomain$fastcgi_script_name;
}

location ~ .*.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$
{
expires 30d;
}

location ~ .*.(js|css)$
{
expires 12h;
}

access_log off; #access_log end
error_log /dev/null; #error_log end
}

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Shanna517

1 Comments

Sorted by latest first Latest Oldest Best

 

@Phylliss660

For HTTP basic authentication using a .htpasswd file, use the auth_basic module in a location block for the protected directory:

location /123 {
auth_basic "Protected";
auth_basic_user_file /path/to/.htpasswd;
}

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme