今日客户服务器攻防演练,扫出了不少网站的安全问题,通过以下设置,可以通过绿盟的漏扫。

以下配置都是基于Nginx的反向代理。

server {
	listen	8080;
	server_name  ocm.shengu.com.cn;
        #安全配置开始
        #处理缺少头信息的安全问题
        add_header Content-Security-Policy "default-src 'self' data: *.shengu.com.cn  'unsafe-inline' 'unsafe-eval' mediastream: ";
        add_header X-Content-Type-Options "nosniff";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Frame-Options SAMEORIGIN;
        add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
        add_header Referrer-Policy "origin"; 
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        #cookie设置httponly
        add_header Set-Cookie "HttpOnly";
        #禁用不安全的http方法
        if ($request_method ~* OPTIONS|DELETE|SEARCH|COPY|MOVE|PROPFIND|PROPPATCH|MKCOL|LOCK|UNLOCK) {
                return 403;
        }
        #安全配置结束
	location / {
		proxy_pass http://127.0.0.1:80;
		proxy_set_header X-real-ip $remote_addr;
		proxy_set_header Host $http_host;
	}

}

重启Nginx:

nginx -s reload