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