可以对admin.php访问进行控制
location ~ .*admin\.php$ {
allow 127.0.0.1;
deny all;
include fastcgi_params;
fastcgi_pass unix:/tmp/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
也可以针对全局配置
server
{
listen 80;
server_name www.test1.com www.aaa1.com www.bbb1.com;
if ($host != 'www.test1.com')
{
rewrite ^/(.*)$ http://www.test1.com/$1 permanent;
}
index index.html index.htm index.php;
root /data/www;
access_log /tmp/access.log 123123
* deny 1.1.1.1
* deny ip
location ~ .*admin\.php$ {
auth_basic "123123 auth";
auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
include fastcgi_params;