vi /etc/nginx/conf.d/bbs.aaa.com.conf
allow 127.0.0.1; //現實生產中,該白名單地址應設置爲公司外網地址/或地址段。 deny all;
[root@localhost ~]# curl -x127.0.0.1:80 bbs.aaa.com -I HTTP/1.1 200 OK Server: nginx/1.14.2 Date: Tue, 19 Feb 2019 17:05:28 GMT Content-Type: text/html; charset=utf-8 Connection: keep-alive X-Powered-By: PHP/7.3.2 [root@localhost ~]# curl -x192.168.254.128:80 bbs.aaa.com -I HTTP/1.1 403 Forbidden Server: nginx/1.14.2 Date: Tue, 19 Feb 2019 17:05:38 GMT Content-Type: text/html Content-Length: 169 Connection: keep-alive
deny 127.0.0.1;
[root@localhost ~]# curl -x127.0.0.1:80 bbs.aaa.com -I HTTP/1.1 403 Forbidden Server: nginx/1.14.2 Date: Tue, 19 Feb 2019 17:14:08 GMT Content-Type: text/html Content-Length: 169 Connection: keep-alive
location /admin/ { allow 127.0.0.1; deny all; }
[root@localhost ~]# curl -x192.168.254.128:80 bbs.aaa.com/admin/ -I HTTP/1.1 403 Forbidden Server: nginx/1.14.2 Date: Tue, 19 Feb 2019 17:24:27 GMT Content-Type: text/html Content-Length: 169 Connection: keep-alive [root@localhost ~]# curl -x127.0.0.1:80 bbs.aaa.com/admin/ -I HTTP/1.1 404 Not Found Server: nginx/1.14.2 Date: Tue, 19 Feb 2019 17:24:53 GMT Content-Type: text/html Content-Length: 169 Connection: keep-alive
location ~ .*(upload|image)/.*\.php$ { deny all; }
if ($http_user_agent ~ 'Spider/3.0|YoudaoBot|Tomato') { return 403; }
什麼是URI?參考 https://baike.baidu.com/item/URI/2901761?fr=aladdinphp
if ($request_uri ~ (abc|123)) { return 404; }
curl有不少使用方法,可參考: http://www.javashuo.com/article/p-usdmlmbu-m.htmlhtml