小程序https的配置

版权声明: https://blog.csdn.net/qq_15901351/article/details/87971430

这里以阿里云服务器为案例。

参考:https://blog.csdn.net/u011982687/article/details/81317290

https://help.aliyun.com/document_detail/98728.html?spm=a2c4g.11186623.2.16.320f20c6JJApDc#concept-n45-21x-yfb

一、申请ssl证书

https://www.cnblogs.com/dekevin/p/10226797.html

二、下在对应的服务器SSL证书安装指南

这个以nginx为例:http://www.cnblogs.com/lemonphp/p/9876781.html

https://yq.aliyun.com/articles/191150

1. 下载nginx的包,解压后,含有以下文件

2. 我把nginx安装在/usr/local/nginx 这个目录下.,进入conf文件夹进行配置:

3.创建cert文件夹存放以上2个文件(key/pem)

4.编辑nginx.conf,将https server放开注释

#http 

server {
        listen  80;
        server_name  '域名';
        location / {
        proxy_pass http://127.0.0.1:8005/;
        proxy_set_header   Host    $host;
        proxy_set_header   X-Real-IP   $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

 # HTTPS server

server {
        listen  80; 
        listen  443;
        server_name  “ip地址对应的域名“”;
        ssl on;
        ssl_certificate      cert/hxyy.pem;
        ssl_certificate_key  cert/hxyy.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;
                location / {
                proxy_pass http://127.0.0.1:8006/;  //代理本地地址夹端口
                proxy_set_header   Host    $host;
                proxy_set_header   X-Real-IP   $remote_addr;
                proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
                }
    }

5.重启nginx ./nginx -s reload

6.访问: https://xxx/,可以查看ssl证书,配置成功

注意:Nginx配置SSL报错 nginx: [emerg] unknown directive "ssl"

以下解决方案:https://blog.csdn.net/weiyangdong/article/details/80008543 

猜你喜欢

转载自blog.csdn.net/qq_15901351/article/details/87971430