Nginx使用中出現的一些問題


TLS版本過低

控制台提示: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"

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM