nginx允许或拒绝get/post/put/delete请求

发布时间:2018-12-26编辑:佚名阅读(6630)

只允许get/post请求

if ($request_method !~* GET|POST)
{
    return 403;
}
#或者
if ($request_method !~ ^(GET|POST)$)
{
    return 403;
}

拒绝PUT、DELETE、POST请求

if ($request_method = PUT){
    return 403;
}
if ($request_method = DELETE){
    return 403;
}
if ($request_method = POST){
    return 403;
}

注意:if和(之间要有一个空格,否则会报错。要放在server层里面。

server{
   #放这里
}


  关键字:nginx允许拒绝getpostputdelete请求


鼓掌

3

正能量

1

1

呵呵

1


评论区