在nginx的配置文件中,将location /下的IF条件中的$request_method参数设置允许的请求类型 仅允许Get server { #禁止post/put if ($request_method !~ ^(GET)$ ){ return 403; } ... } 仅允许GET和POST location / { if ($request_method !~ ^(GET|POST)$ ) { return 403; } ... }