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 m.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 m.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ā)表評論

越西县| 庆阳市| 定结县| 保定市| 伽师县| 乌苏市| 三亚市| 饶河县| 宁晋县| 长岛县| 乡宁县| 义乌市| 天门市| 滦平县| 钦州市| 平泉县| 上饶县| 沁源县| 保靖县| 太仓市| 怀化市| 手游| 井研县| 栖霞市| 嵩明县| 巫山县| 怀远县| 彭山县| 洛川县| 台南县| 宝坻区| 四平市| 马公市| 富阳市| 柯坪县| 新宾| 高碑店市| 赤城县| 盘山县| 新宁县| 西昌市|