簡體   English   中英

Nginx-無法使用htaccess Nginx保護目錄

[英]Nginx - Unable to secure directory with htaccess nginx

我需要在運行Nginx的Ubuntu Server 12.04中保護特定文件夾。

我遵循了本教程: http : //nginxlibrary.com/password-protect-a-directory/和許多其他喜歡它的人。

我使用apache utils創建了一個名為.htpasswd的文件,並將其放在/ etc / nginx / passwords中

然后轉到配置文件中的服務器塊並放入

location /var/www/mywebsitedir.com/folderthatneedsprotection {
    auth_basic "Restricted Area";
    auth_basic_user_file /etc/nginx/passwords/.htpasswd;
}

我還嘗試了許多位置指令的變體,例如使用通配符^〜等,但仍然無法正常工作。 我確實需要用密碼保護目錄,但是它似乎不起作用! 任何幫助是極大的贊賞。

請注意,您嘗試在location指令中使用路徑和url的組合。 取而代之的是,它僅應在域之后包含相對URL。

就您而言,這很可能是:

location /folderthatneedsprotection {
    auth_basic "Restricted Area";
    auth_basic_user_file /etc/nginx/passwords/.htpasswd;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM