一.需求描述

公司为了保证网络安全,所有系统访问网址需要采取https+域名(隐藏端口)的形式进行访问

二.解决思路

1.通过openssl生成秘钥、p10证书申请(或者CSR文件生成工具-中国数字证书CHINASSL)

2.在证书服务器通过p10证书申请下载证书

3.通过nginx配置代理

三.详细步骤

1.windows安装openssl http://slproweb.com/products/Win32OpenSSL.html

2.找到openssl安装目录下的bin目录,进入cmd命令(如果嫌麻烦,可以在系统环境变量里面配置,每次执行命令就不用到指定目录)

 

3.执行命令

生成私钥

openssl  genrsa -out  E:/keystore/uat.key

 生成证书申请

openssl req -new -key E:/keystore/uat.key -passin pass:12345 -out E:/keystore/P10.key

4.复制P10.key里面的内容,登录到公司部署的证书服务网址,粘贴然后生成证书

 

 5.将生成的cer证书和私钥uat.key放到安装好的nginx指定目录下

6.配置nginx.conf

server {
        listen       443 ssl;
        server_name  xx.xx.com;

        #ssl on;
        ssl_certificate D:/nginx/conf/uat.cer;      
        ssl_certificate_key D:/nginx/conf/uat.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
        location /{
            proxy_pass   http://127.0.0.1:8080;
        }

        #error_page  404              /404.html;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

 7.启动nginx,访问https网址

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐