用戶認證

server

{

    listen 80;

    server_name www.test1.com;

    index index.html index.htm index.php;

    root /data/www;

    location ~ .*admin\.php$ {

        auth_basic "123123 auth";

        auth_basic_user_file /usr/local/nginx/conf/.htpasswd;

include fastcgi_params;

        fastcgi_pass unix:/tmp/www.sock;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

}

    location ~ \.php$ {

        include fastcgi_params;

        fastcgi_pass unix:/tmp/www.sock;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

    }


}


 htpasswd -c -m /usr/local/nginx/conf/htpasswd test

/etc/init.d/nginx reload




目錄認證

server

{

    listen 80;

    server_name www.test1.com;

    index index.html index.htm index.php;

    root /data/www;

    localtion ~ /tmp/ {      

        auth_basic "123123 auth";

        auth_basic_user_file /usr/local/nginx/conf/.htpasswd;

}

    location ~ \.php$ {

        include fastcgi_params;

        fastcgi_pass unix:/tmp/www.sock;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

    }


}

 curl -x127.0.0.1:80 -uaming:123123 www.test1.com/admin.php


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章