Nginx配置https

上传文件到linux

java 复制代码
[root@zonghe01 nginx24]# pwd
/data/nginx24
[root@zonghe01 nginx24]# mkdir ssl
[root@zonghe01 ssl]# ll
total 8
-rw-r--r-- 1 root root 1675 Nov 15 22:19 xxx1.key
-rw-r--r-- 1 root root 3834 Nov 15 22:19 xxx2.pem

修改配置监听

java 复制代码
server {
        listen 8888 ssl;
        server_name xxx.gov.cn;
        underscores_in_headers on;
        ssl_certificate     /data/nginx24/ssl/xxx1.pem;
        ssl_certificate_key /data/nginx24/ssl/xxx2.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSV1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_prefer_server_ciphers on;

        #location / {
         #   root   html;
          #  index  index.html index.htm;
        #}
         location  /audit/ {
          alias /data/web/audit/lvfa_web/;
          index index.html /data/web/audit/lvfa_web/index.html;
        }
        location /minio/ {
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                #proxy_set_header Host lft.xxx.com;
                proxy_set_header   Host $http_host;
                proxy_pass http://127.0.0.1:9000/;
        }

         location /api2/ {
                        proxy_pass http://http_res;
                        proxy_http_version 1.1;
                        proxy_set_header   Host $http_host;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection "upgrade";
        }
         location /api/ {
                        proxy_pass http://http_res;
                        proxy_http_version 1.1;
                        proxy_set_header   Host $http_host;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection "upgrade";
        }

nginx的ngx_stream_core_module模块,但是该模块在安装时不是默认构建的,需要在编译安装执行 ./configure时加上参数--with-http_ssl_module

java 复制代码
使用命令./nginx -V查看,如果在configure arguments后面没有出现--with-http_ssl_module则说明没有安装此模块
[root@test sbin]# cd /usr/local/nginx/sbin/
[root@test sbin]# ./nginx -Vnginx version: nginx/1.24.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) 
configure arguments: --prefix=/usr/local/nginx
[root@test sbin]#

平滑安装https模块(如果之前没配置https模块)

java 复制代码
# 找到nginx源码目录,如此处nginx源码目录为:/home/nginx/nginx-1.24.0,即为编译命令执行目录
cd /data/nginx-1.24.0
# 执行编译命令
./configure --prefix=/data/nginx24 --with-http_ssl_module
# 执行make,此处一定不能使用make install命令,执行该命令会将原有nginx目录进行覆盖
make
# 关掉nginx
cd /data/nginx24/sbin/
./nginx -s stop# 
备份原有nginx二进制文件。
cp /data/nginx24/sbin/nginx /data/nginx24/sbin/nginx-no-https
# 复制新编译好的nginx二进制文件。从此处nginx源码目录为:/data/nginx-1.24.0。即为编译命令执行目录。
cp /data/nginx-1.24.0/objs/nginx /data/nginx24/sbin/nginx24
# 重新启动服务
cd /data/nginx24/sbin/
./nginx
# 可以通过./nginx -V命令查看以下模块是否安装成功
相关推荐
2501_9151063211 小时前
苹果App Store上架费用及流程全面解析
android·ios·小程序·https·uni-app·iphone·webview
阿标在干嘛17 小时前
Nginx一个配置错误,流量损失30%!这是我们的完整排查记录
运维·nginx
为思念酝酿的痛17 小时前
应用层协议HTTPS
网络·网络协议·http·https
IPdodo_18 小时前
curl 如何测试代理 IP?HTTP、SOCKS5 与认证参数示例
前端·网络·python·https·网络调试
隐擎fox1 天前
深入理解网络传输层安全:TLS 指纹识别(JA3/JA4)原理与 Python 协议层检测实战
爬虫·python·网络协议·安全·网络安全·https
游戏开发爱好者81 天前
网络连接排查指南,谁在电脑后台偷跑流量,哪些程序在联网
网络协议·计算机网络·网络安全·ios·adb·https·udp
IT菜鸟程2 天前
Ubuntu 下 apt 版 Nginx 升级为源码编译版本完整操作指南(1.24.0 → 1.30.4 实战)
linux·nginx·ubuntu
sbjdhjd2 天前
从 7 字符文件名拼接到二维数组取值:PHP 无参函数限制下的受控靶场复盘 | (7字符绕过)
网络·nginx·安全·网络安全·云计算·php·apache
NGINX开源社区2 天前
NGINX Gateway Fabric 2.6:F5 WAF for NGINX 集成 Gateway API
nginx·gateway·fabric
小白羊丨2 天前
HTTP/2 如何缓解 HTTP/1.1 阻塞;长连接对 Nginx 有什么影响?
网络协议·nginx·http