最近發(fā)現(xiàn)有些攻擊利用post請求繞過百度云加速防火墻的情況
這種情況我們直接禁掉服務(wù)器POST請求是不是好些呢,所以主機吧找了個代碼放置在nginx.conf文件上,試了下,果然是有效果的,代碼如下:
upstream tomcat {ip_hash;server 192.168.2.187:8080;}location ~* / {if ($request_method = PUT ) {return 403;}if ($request_method = DELETE ) {return 403;}if ($request_method = POST ) {return 403;}proxy_method GET;proxy_pass http://tomcat;}
當路徑包含/的時候,則代理到server后端進行請求數(shù)據(jù)。這里屏蔽了PUT,DELETE,POST方法,只是使用了GET。