Nginx配置问题汇总

2、是否限制可用的方法----------if ($request_method !~ ^(GET|HEAD|POST)$ ) {return 444; }在哪里配置?
---该段代码的作用是屏蔽非GET、HEAD或POST类型请求,返回XXX状态码。
     根据作用范围,配置在server、location中都可以。
     参考:
   server {
       listen  8083;
       server_name  localhost;
        if ($request_method !~ ^(GET|HEAD|POST)$ )
        {
            return 403;
       }
   ……
          }

3、是否存在目录遍历 ----------没有autoindex参数是否合格?
---nginx默认autoindex为off,一般不需要配置。
      ngx_http_autoindex_module配置参考:http://wiki.nginx.org/NginxChsHttpAutoindexModule
http://www.ctohome.com/FuWuQi/46/375.html
      配置参考:
      location ^~/ui/ {
            root   /netapp/applications/NetbWeb4;
            expires max;
            autoindex on;
            autoindex_exact_size off;
            autoindex_localtime on;
        }

配置前访问效果



配置后访问效果





4、是否存在文件类型解析漏洞----------location 节点中无try_files $fastcgi_script_name = 404;是否合格?
---1)该漏洞应该是针对nginx解析php的,目前我们的应用没有使用php,并已在nginx配置中设有屏蔽,如下
location ~* \.(php|asp|aspx)$ {
    rewrite ^(.*) http://172.19.67.1:8083/404.html redirect;
      }
   2)若应用中采用php,则可以采用以下方式解决
       关闭cgi.fix_pathinfo为0
      或者
       if ( $fastcgi_script_name ~ \..*\/.*php ) {
           return 403;
       }
     参考:http://www.80sec.com/nginx-securit.html

猜你喜欢

转载自kld208.iteye.com/blog/1625415