nginx配置只允许某个ip或某些ip进行访问
在server下配置如下,即成实现只允许某些ip对web的访问了
server
{
listen 80;
#listen [::]:80;
server_name a.com ;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/a.com;
if ( $remote_addr !~* "223.184.203.125|223.184.203.131") {#只这些ip访问
return 403;
}
include other.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
}

浙公网安备 33010602011771号