小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Nginx服務(wù)器拒絕非GET方式請求保障安全性

 WindySky 2016-03-30

  upstream tomcat {
ip_hash;
server 192.168.2.187:8080;
}

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) {
# return 404;
rewrite ^/(.*) /index.html;                                                                        };

nginx禁止訪問txt|doc文件                              
方法一:全局設(shè)置,禁止訪問任何以后綴txt|doc的文件
        location ~* \.(txt|doc)$ {
        deny all;
        }

方法二:只禁止訪問某目錄下的txt|doc
        location ~* \.(txt|doc)$ {
        if (-f $request_filename) { Linux學(xué)習(xí),http:// linux.
        root html/job;
        break;
         }
   }

nginx禁止某中瀏覽器訪問:#瀏覽器類型可從日志得知。
server
       {
               listen       80;
               server_name  test.domain.com;
               index index.php index.html;
               root   /opt/nginx/html/;
               if ( $http_user_agent ~* "MSIE 6.0" ) {
               return 403;
                }

設(shè)置目錄執(zhí)行權(quán)限                                                                                 
在windows+iis下,可以設(shè)置上傳目錄,類似:upload,uploadfile,attachments,這樣的目錄下面無腳本執(zhí)行權(quán)限,從而防止非法用戶上傳腳本得到webshell

nginx上也很簡單,我們使用location 如下:

location ~ ^/upload/.*\.(php|php5)$
{
deny all;
}

其中upload換為你要設(shè)置的目錄名字 Linux學(xué)習(xí),http:// linux.

這條規(guī)則的含義是匹配請求連接中開頭是/upload/,中間匹配任意字符,結(jié)尾匹配.php或者.php5的頁面,最后利用deny all禁止訪問,這樣就防止了上傳目錄的腳本執(zhí)行權(quán)限

(責(zé)任編輯:IT)

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多