官方文档: https://nginx.org/en/docs/http/ngx_http_access_module.html
官方案例
语法
Syntax: allow address | CIDR | unix: | all;Default: —Context: http, server, location, limit_exceptAllows access for the specified network or address. If the special value unix: is specified (1.5.1), allows access for all UNIX-domain sockets.
确认nginx安装的时候加入了 ngx_http_access_module 这个模块
随后在想要进行访问控制的路径进行配置
location /admin {allow 172.16.1.100; #允许访问deny all; #不允许访问}


