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/
執行效果如下: