upstream tomcat {
ip_hash;
server 192.168.2.187:8080;
}
location ~* /html {
if ($request_method = PUT ) { IT网,http://www.it.net.cn
return 403;
}
if ($request_method = DELETE ) {
return 403;
}
if ($request_method = POST ) { IT网,http://www.it.net.cn
return 403;
}
proxy_method GET;
proxy_pass http://tomcat; Linux学习,http:// linux.it.net.cn
}
当路径包含/html的时候,则代理到server后端进行请求数据。这里屏蔽了PUT,DELETE,POST方法,只是使用了GET,主要目的是为了安全性,因为DELETE,POST,PUT是可以修改数据的。
或者:
limit_except GET { IT网,http://www.it.net.cn
allow 192.168.1.1;
deny all;
} IT网,http://www.it.net.cn
if ($request_filename ~ /test/index.html) {
# return 404;
rewrite ^/(.*) /index.html;
方法二:只禁止访问某目录下的txt|doc
nginx禁止某中浏览器访问:#浏览器类型可从日志得知。
server
设置目录执行权限 nginx上也很简单,我们使用location 如下: location ~ ^/upload/.*\.(php|php5)$ 其中upload换为你要设置的目录名字 Linux学习,http:// linux.it.net.cn 这条规则的含义是匹配请求连接中开头是/upload/,中间匹配任意字符,结尾匹配.php或者.php5的页面,最后利用deny all禁止访问,这样就防止了上传目录的脚本执行权限 (责任编辑:IT)
在windows+iis下,可以设置上传目录,类似:upload,uploadfile,attachments,这样的目录下面无脚本执行权限,从而防止非法用户上传脚本得到webshell
{
deny all;
}
联系客服