首选可以在阿里云申请证书,有免费的证书,可以申请
可以参考:SSL证书安装指南:
https://help.aliyun.com/knowledge_detail/95505.html?spm=5176.2020520163.cas.7.2fcc56a76Dft2C
阿里下载下来的证书类似下图压缩包
然后把两个证书放到nginx目录里面
接着配置nginx
代码:
server {
listen 80; # 监听端口
server_name test.com; # 站点域名
index index.html index.htm ; # 默认导航页
location /manageapi/{
root /home/wwwroot/manage;
rewrite ^.+manageapi/?(.*)$ /$1 break;
include uwsgi_params;
proxy_pass http://127.0.0.1:8083;
}
location /mallapi/{
root /home/wwwroot/manage;
rewrite ^.+mallapi/?(.*)$ /$1 break;
include uwsgi_params;
proxy_pass http://127.0.0.1:8079;
}
location / {
root /home/wwwroot/manage;
try_files $uri $uri /index.html;
index index.html index.htm;
}
access_log /home/wwwlogs/manage-access.log;
}
server {
listen 443; # 监听端口
server_name test.com; # 站点域名
index index.html index.htm ; # 默认导航页
ssl on;
ssl_certificate cert/2689619_upingou.sxcy100.com.pem;
ssl_certificate_key cert/2689619_upingou.sxcy100.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location /manageapi/{
root /home/wwwroot/manage;
rewrite ^.+manageapi/?(.*)$ /$1 break;
include uwsgi_params;
proxy_pass http://127.0.0.1:8083;
}
location /mallapi/{
root /home/wwwroot/manage;
rewrite ^.+mallapi/?(.*)$ /$1 break;
include uwsgi_params;
proxy_pass http://127.0.0.1:8079;
}
location / {
root /home/wwwroot/manage;
try_files $uri $uri /index.html;
index index.html index.htm;
}
access_log /home/wwwlogs/httpsmanage-access.log;
}
然后重启nginx即可