upstream tomcat {
ip_hash;
server 192.168.2.187:8080;
}
location ~* /html {
if ($request_method = PUT ) { IT網(wǎng),http://www.it.net.cn
return 403;
}
if ($request_method = DELETE ) {
return 403;
}
if ($request_method = POST ) { IT網(wǎng),http://www.it.net.cn
return 403;
}
proxy_method GET;
proxy_pass http://tomcat; Linux學(xué)習(xí),http:// linux.it.net.cn
}
當(dāng)路徑包含/html的時(shí)候,則代理到server后端進(jìn)行請(qǐng)求數(shù)據(jù)。這里屏蔽了PUT,DELETE,POST方法,只是使用了GET,主要目的是為了安全性,因?yàn)镈ELETE,POST,PUT是可以修改數(shù)據(jù)的。
或者:
limit_except GET { IT網(wǎng),http://www.it.net.cn
allow 192.168.1.1;
deny all;
} IT網(wǎng),http://www.it.net.cn
if ($request_filename ~ /test/index.html) {
# return 404;
rewrite ^/(.*) /index.html;
方法二:只禁止訪問(wèn)某目錄下的txt|doc
nginx禁止某中瀏覽器訪問(wèn):#瀏覽器類(lèi)型可從日志得知。
server
設(shè)置目錄執(zhí)行權(quán)限 nginx上也很簡(jiǎn)單,我們使用location 如下: location ~ ^/upload/.*\.(php|php5)$ 其中upload換為你要設(shè)置的目錄名字 Linux學(xué)習(xí),http:// linux.it.net.cn 這條規(guī)則的含義是匹配請(qǐng)求連接中開(kāi)頭是/upload/,中間匹配任意字符,結(jié)尾匹配.php或者.php5的頁(yè)面,最后利用deny all禁止訪問(wèn),這樣就防止了上傳目錄的腳本執(zhí)行權(quán)限 (責(zé)任編輯:IT)
在windows+iis下,可以設(shè)置上傳目錄,類(lèi)似:upload,uploadfile,attachments,這樣的目錄下面無(wú)腳本執(zhí)行權(quán)限,從而防止非法用戶上傳腳本得到webshell
{
deny all;
}
聯(lián)系客服