Nginx使用中出现的一些问题

1. 控制台提示:The connection used to load resources from https://xxx.test.com used TLS 1.0 or TLS 1.1, which are deprecated and will be disabled in the future. Once disabled, users will be prevented from loading these resources. The server should enable TLS 1.2 or later. See https://www.chromestatus.com/feature/5654791610957824 for more information.

这是由于TLS版本过低导致,需要升级openssl版本(1.0.1以上的版本支持 TLS1.2,1.1.1以上的版本支持 TLS1.3)并重新编译nginx

openssl升级可以参考另外一篇文章,这里只贴出nginx编译升级的过程

# nginx编译升级
# 安装所需依赖(openssl编译升级过的无需通过yum安装)
yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel
# 下载安装包
cd ~ && wget https://nginx.org/download/nginx-1.17.1.tar.gz
# 解压
tar -zxf nginx-1.17.1.tar.gz
# 查看nginx启用的模块
nginx -V > /root/test.txt 2>&1
modules=`cat /root/test.txt |awk -F':' 'NR==5{print $2}'`
# 编译升级(切勿make install)
cd nginx-1.17.1 && ./configure $modules && make
# 备份nginx执行文件
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx-bak
# 替换新版本nginx执行文件
nginx -s quit && cp objs/nginx /usr/local/nginx/sbin/nginx
# 启动nginx服务
/usr/local/nginx/sbin/nginx
# 批量注释以前的配置
for i in `ls`;do echo sed -i 's/^ssl_protocols/#&/' $i;done
# 指定内容的下一行添加配置(/a)
for i in `ls`;do sed -i '/#ssl_protocols/assl_protocols TLSv1 TLSv1.1 TLSv1.2;' $i;done
# 启用所有协议,禁用已废弃的不安全的SSLv2和SSLv3(必须在所有站点中配置以下参数才能生效,上面的sed已添加)
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

注意:./configure $modules时,如openssl编译升级过的,需要指定路径:./configure xxxxx --with-openssl=/usr/local/include/openssl

如仍然报错找不到openssl模块等,需要修改nginx源码包openssl的配置文件

vim /root/nginx-1.17.1/auto/lib/openssl/conf
# 将以下配置进行相应的修改(find一下就知道路径各个模块的路径了)
# $OPENSSL变量的值是--with-openssl指定的路径

            CORE_INCS="$CORE_INCS $OPENSSL/"
            CORE_DEPS="$CORE_DEPS $OPENSSL/ssl.h"
            CORE_LIBS="$CORE_LIBS /usr/local/lib64/libssl.a"
            CORE_LIBS="$CORE_LIBS /usr/local/lib64/libcrypto.a"
            CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
原文地址:https://www.cnblogs.com/cpw6/p/13364729.html