Nginx 关闭/屏蔽 PUT、DELETE、OPTIONS 请求(漏洞修复)

Nginx 关闭/屏蔽 PUT、DELETE、OPTIONS 请求


1、修改 nginx 配置

在 nginx 配置文件中,增加如下配置内容:

if ($request_method !~* GET|POST|HEAD) {
 return 403;
}

修改效果如下:

2、重启 nginx 服务

systemctl restart nginx

或者

service nginx restart

3、功能验证

使用如下方式验证(可以使用 IntelliJ IDEA 自带的 Http request 工具,很方便,强烈推荐!!!)

DELETE http://localhost:8080/
#PUT http://localhost:8080/
#OPTIONS http://localhost:8080/

执行效果如下:

原文地址:https://www.cnblogs.com/miracle-luna/p/14274445.html