Nginx——如何禁用TLSv1.0和TLSv1.1

简介: Nginx——如何禁用TLSv1.0和TLSv1.1

前言

Web安扫提示Nginx使用了不安全的加密协议需要启用TLSv1.2或者更高的协议,但是修改后还是一直扫出了TLSv1.0和TLSV1.1,总结下原因;

工具1: http://s.tool.chinaz.com/https

工具2: https://infinisign.com/tools/sslcheck/?lang=cn

工具3: acunetix

内容

存在多个虚拟主机文件

针对存在多个虚拟主机文件的Nginx解析,每个虚拟主机文件都需要修改;

Nginx的openssl套件不支持

配置符合PFS规范的加密套件

ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE

开启优先使用服务端加密套件

ssl_prefer_server_ciphers on;

配置示例

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_certificate /usr/local/nginx/conf/ssl/www.wangyangyang.vip.pem;
  ssl_certificate_key /usr/local/nginx/conf/ssl/www.wangyangyang.vip.key;
  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  ssl_prefer_server_ciphers on;
  ssl_session_timeout 10m;
  ssl_session_cache builtin:1000 shared:SSL:10m;
  ssl_buffer_size 1400;
  add_header Strict-Transport-Security max-age=15768000;
  ssl_stapling on;
  ssl_stapling_verify on;
  server_name www.wangyangyang.vip;
  access_log /data/wwwlogs/www.wangyangyang.vip_nginx.log combined;
  index index.html index.htm index.php;
  root /data/wwwroot/www.wangyangyang.vip/build;
  if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
  
  include /usr/local/nginx/conf/rewrite/none.conf;
  #error_page 404 /404.html;
  #error_page 502 /502.html;
  
  location ~ [^/]\.php(/|$) {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  }
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    expires 30d;
    access_log off;
  }
  location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
  }
  location ~ /(\.user\.ini|\.ht|\.git|\.svn|\.project|LICENSE|README\.md) {
    deny all;
  }
}

提示

如果都设置了还不行,那就ping下域名看下对应的ip是否一致,不一致那就到对应的机器上进行修改;

学无止境,谦卑而行.

目录
打赏
0
0
0
0
67
分享
相关文章
nginx 配置总结
# Nginx 常用配置 ## 为什么写这篇文章? 1. 在工作中发现很多开发者只关注于开发,认为 nginx 属于运维的事,然而无论大小公司,开发中都会涉及到一部分服务器配置,小公司基本都是开发和运维一体。即使是大公司可能也会涉及到一些 cors、特殊 http 头配置问题。尤其是 cors,很多人不知道完整的 http 配置 2. 一些人想搭建自己的服务器,但是服务器不太会配置
459 0
一系列nginx安全配置
一、模块 1.查看所有模块: [root@proxy nginx-1.12.2]# ./configure --help 2.选择适合的模块:pcre:开启正则表达式支持http_autoindex_module:自动索引模块ssi_module:SSI 脚本http_ssl_module:ss...
2137 0
nginx 1.13.0的配置文件设置
nginx 1.13.0的配置文件设置 看到网上一大堆教程安装和使用,本想着应该没有什么问题,不过在更改nginx的配置文件来做一个视频点播系统的时候就遇到一对麻烦:就是没有改对配置文件!! nginx  版本:nginx 1.
1477 0
Nginx 配置
nginx配置文件 alias的作用就是转发 --> 相当于一个location块接收到了一个请求, 通过alias重新指定URL后面的资源路径, 在不通知浏览器的情况下, 在服务器内部转发alias之后的URL 注意: 在httpd中的alias不是转发, 而是一个根切换 在书写location...
966 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等