中文字幕亚洲一区,69久久久久精品9999不卡片,亚洲国产日韩欧美在线看片,国产精品久久久久久久久岛国

龍巖易富通網絡科技有限公司

龍巖小程序開發,龍巖分銷系統

nginx配置Http Basic Auth保護目錄

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

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

htpasswd -b -c site_pass username password

例如:基于整個網站的認證,auth_basic在php解釋之前。 

server { 

   listen 80; 

   server_name www.co197.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; 

}

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

auth_basic在嵌套的location之后。 

server { 

   listen 80; 

   server_name www.co197.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還是可以訪問并且運行的。 

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



htpasswd.zip


贊 (

發表評論

主站蜘蛛池模板: 灵丘县| 滨海县| 广西| 苏州市| 璧山县| 龙岩市| 平顺县| 昌宁县| 伊吾县| 兴安县| 金沙县| 浦县| 房产| 华池县| 汝城县| 宁强县| 高平市| 霞浦县| 肥城市| 吉木乃县| 南靖县| 临朐县| 昌吉市| 昆明市| 应用必备| 青神县| 郸城县| 宝丰县| 屏东市| 六枝特区| 陕西省| 蒲江县| 阜新| 定陶县| 宁津县| 九江市| 贵德县| 濮阳县| 建阳市| 清新县| 永善县|