1.下载证书
阿里云为例 下载 nginx版本
nginx安装配置SSL证书实现https访问_ssl证书

2.将证书解压后的文件放入root下的card(没有则新建目录)

nginx安装配置SSL证书实现https访问_ssl证书_02

3.cd etc/nginx/下修改nginx.conf

443端口
nginx安装配置SSL证书实现https访问_重启_03
代理端口
nginx安装配置SSL证书实现https访问_重启_04

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
  server {
  #监听443端口
    listen 443;
    #你的域名
    server_name yssy.cloud; 
    ssl on;
    #ssl证书的pem文件路径
    ssl_certificate  /root/card/yssy.cloud.pem;
    #ssl证书的key文件路径
    ssl_certificate_key /root/card/yssy.cloud.key;
    location / {
     proxy_pass  http://公网地址:项目端口号;
    }
}
server {
    listen 8082;
    server_name yssy.cloud;
    #将请求转成https
    rewrite ^(.*)$ https://$host$1 permanent;
}
}

4.重启nginx

进入sbin目录下

./nginx -s reload
./nginx -s stop
./nginx