0
点赞
收藏
分享

微信扫一扫

nginx通过limit_except 配置客户端可以使用的方法

萍儿的小确幸 2024-11-04 阅读 6
nginx运维

limit_except 仅可以用于location。禁止客户端使用除了指定的请求方法之外的其它方法,如果使用会出现403错误。

可以控制的方法包括:method:GET, HEAD, POST, PUT, DELETE,MKCOL, COPY, MOVE, OPTIONS, PROPFIND,PROPPATCH, LOCK, UNLOCK, PATCH

配置示例:(除了get和head方法之外,其它方法仅允许172.16.0.0/24网段主机使用 )

[root@localhost conf.d]# vi uhn.conf 

server {
   listen 80;
   server_name www.uhn.cn;

   error_page 500 502 503 504  /error.html;
   location = /error.html {
   root /data/nginx/html/uhn;
   }

   location / {
   root /data/nginx/html/uhn;
   try_files $uri $uri.html $uri/index.html =911;
#   auth_basic "login password";
#   auth_basic_user_file /software/nginx/conf/.htpasswd;
   }

   location /upload {
   root /data/nginx/html/pc;
   index index.html;
   limit_except GET {
   allow 172.16.0.0/24;
   deny all;
   }
}

举报

相关推荐

0 条评论