在Server段中新增一段代码

if ($request_method !~ ^(GET|POST|DELETE|PUT|PATCH|HEAD|OPTIONS)$ )     {
		return  444;
}

还有一种方式就是在location里面添加限制方式

location / {
	limit_except GET POST {  # 限制除了get,post的方法之外,全部拒绝
			deny all;
	}
}}
}