nginx访问控制
访问控制
用于location段
allow:设定允许哪台或哪些主机访问,多个参数间用空格隔开
deny:设定禁止哪台或哪些主机访问,多个参数间用空格隔开
[root@localhost conf]# vim nginx.conf
location /test {
deny 192.168.100.123;
echo "lalala";
}
[root@localhost conf]# nginx -s reload
[root@localhost ~]# curl 192.168.100.123/test
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.20.1</center>
</body>
</html>
[root@localhost ~]# curl 192.168.100.123
<!DOCTYPE html>
<html>
<head>
<title>Error</title>
<style>
body {
width: