随着Https的大量应用,几乎所有网站都使用了https的模式。大部分小伙伴可能只是知道https用于加密传输,仅此而已。
对于网站建设,首先要保证网站安全,仅仅配置https是不够的。还需要有一些其他的安全配置。
我们用Nginx配置举例:
1、HTTPS上的传输使用安全标头
nginx配置,server中:
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains" always;
2、https上增加X-XSS-Protection标头。
nginx配置:
add_header "X-XSS-Protection" "1; mode=block";
3、https上需要cookie('PHPSESSID')有“Secure”属性、“HttpOnly”属性。
nginx如下:
proxy_cookie_path / "/; Path=/; Secure; HttpOnly";
4、https配置内容安全策略标头
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
add_header X-XSS-Protection "1; mode=block";
add_header X-fr
add_header X-Content-Type-Options nosniff;
总结:
网站安全不仅仅是代码层面的安全,也包括https的传输安全,以及服务器中间件过滤安全。当然了,还有防火墙、WAF等。欢迎小伙伴一起学习交流。