修改Nginx的站点配置文件nginx.conf
方法一:
在server里添加:
- 写法1
if ( $remote_addr !~* "10.10.141.*|223.184.203.") {#只这些ip访问
return 403;
}
- 写法2
if ($remote_addr !~ ^(192.168.0.*|127.0.0.1)) {
rewrite ^.*$ /errorPage/upgrade.html last;
}
server {
listen 80;
server_name paas.lj-server.com;
if ( $remote_addr !~* "10.10.141.*|223.184.203.") {#只这些ip访问
return 403;
}
client_max_body_size 512m;
access_log /data/bkce/logs/nginx/paas_fqdn_access.log;
......
方法二:
在location里添加
allow 10.10.141;
deny all;
server {
listen 80;
server_name tty.bszhihui.com;
location / {
allow 10.10.141;
deny all;
root /data/wu/web/;
index default.php index.php index.html;
}
error_page 404 403 /error.html;
location = /error.html {
}
......