99热,在线视频免费精品,亚洲综合视频在线观看,久久免费高清视频,九九热视频在线播放,日韩精品在线播放视频,99久久精品免费视频

龍巖易富通網(wǎng)絡(luò )科技有限公司

龍巖小程序開(kāi)發(fā),龍巖分銷(xiāo)系統

nginx配置Http Basic Auth保護目錄

2015.09.10 | 1828閱讀 | 0條評論 | 通用代碼

注意,nginx 的 http auth basic 的密碼是用 crypt(3) 加密的,而apache是md5加密。所以生成時(shí): 

htpasswd -b -c site_pass username password

例如:基于整個(gè)網(wǎng)站的認證,auth_basic在php解釋之前。 

server { 

   listen 80; 

   server_name www.bjsyas.com 0597seo.com; 

   root /wwwroot/0597seo.com; 

   index index.html index.htm index.php; 

   auth_basic "auth"; 

   auth_basic_user_file /usr/local/nginx/auth/nginx_passwd; 

   location ~ .php$ { 

      fastcgi_pass 127.0.0.1:9000; 

     fastcgi_index index.php; 

     include fastcgi_params; 

}

location ~ /\.ht { 

  deny all; 

}

access_log /logs/0597seo.com_access.log main; 

}

針對目錄的認證,在一個(gè)單獨的location中,并且在該location中嵌套一個(gè)解釋php的location,否則php文件不會(huì )執行并且會(huì )被下載。

auth_basic在嵌套的location之后。 

server { 

   listen 80; 

   server_name www.bjsyas.com 0597seo.com; 

   root /wwwroot/0597seo.com; 

   index index.html index.htm index.php; 

   location ~ ^/phpMyAdmin/.* { 

      location ~ \.php$ { 

          fastcgi_pass 127.0.0.1:9000; 

          fastcgi_index index.php; 

          include fastcgi_params; 

    }

 auth_basic "auth"; 

 auth_basic_user_file /usr/local/nginx/auth/auth_phpMyAdmin; 

}

location ~ .php$ { 

  fastcgi_pass 127.0.0.1:9000; 

  fastcgi_index index.php; 

  include fastcgi_params; 

}

location ~ /\.ht { 

  deny all; 

}

access_log /logs/0597seo.com_access.log main; 

}

這里注意,就是location ~ ^/phpMyAdmin/.* {…} 保護phpMyAdmin目錄下的所有文件。

如果你只設了/phpMyAdmin/ 那么直接輸入/phpMyAdmin/index.php還是可以訪(fǎng)問(wèn)并且運行的。 

^/phpMyAdmin/.* 意為保護該目錄下所有文件。



htpasswd.zip


贊 (

發(fā)表評論

天气| 乳山市| 山西省| 新巴尔虎左旗| 汶川县| 梁平县| 凤山市| 四平市| 阿荣旗| 湖南省| 巨鹿县| 和田县| 漯河市| 寻甸| 绥宁县| 三江| 全州县| 台东县| 盈江县| 栾川县| 延川县| 嘉峪关市| 旅游| 屏南县| 齐齐哈尔市| 永春县| 曲周县| 伊宁市| 文登市| 布尔津县| 任丘市| 达拉特旗| 聂荣县| 东源县| 白河县| 武平县| 财经| 民县| 海淀区| 互助| 平江县|