Nginx配置ssl证书

本文介绍了如何在Nginx上配置SSL证书,包括检查SSL依赖、安装缺失模块,以及详细步骤。同时提供了SSL配置示例,强调了关键配置项如`ssl_certificate`和`ssl_certificate_key`,并设置了安全的SSL协议和加密套件。
摘要由CSDN通过智能技术生成

Nginx配置ssl证书

一.检查nginx是否安装SSL的依赖

1.输入命令查询版本信息

windows版本

nginx.exe -V

linux版本

nginx -V

输出结果,检查with-mail_ssl_module是否安装,如果已安装跳过第二步

nginx version: nginx/1.19.4
built by cl 16.00.40219.01 for 80x86
built with OpenSSL 1.1.1h  22 Sep 2020
TLS SNI support enabled
configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msvc8/lib/pcre-8.44 --with-zlib=objs.msvc8/lib/zlib-1.2.11 --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-openssl=objs.msvc8/lib/openssl-1.1.1h --with-openssl-opt='no-asm no-tests -D_WIN32_WINNT=0x0501' --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module

2.安装依赖with-mail_ssl_module

注意:安装依赖需要重装nginx,在重装之前需要备份已安装nginx的配置


在nginx解压的目录下输入命令

./configure --with-http_ssl_module

执行make命令进行编译

make

执行make install命令进行覆盖

make install

将备份好的nginx配置还原即可

二.SSL配置

http{
    server{
        listen 443;
        server_name websocketServer;
        
        # ssl配置
        ssl on;
        ssl_certificate /keystore/server.csr;
        ssl_certificate_key /keystore/server.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;

        location / {
        		#代理地址
                proxy_pass   http://127.0.0.1:8080;
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值