首页 > 技术文章 > 通过nginx实现微信小程序网络API的充要条件

vanuan 2018-08-10 23:33 原文

微信小程序使用网络相关的API有严格要求 ,只支持域名并且需要Https证书。

服务使用springboot,8082端口。

通过nginx 将 https://law.loadpeople.com 反向代理到 http://law.loadpeople.com:8082,并增加SSL证书。

  1. nginx 安装 
  2. SSL数字证书Nginx配置部署指导
  3. 反向代理配置
    #http重写到https
    server {
        listen 80;
        server_name law.loadpeople.com;
        rewrite ^(.*)$ https://$host$1 permanent;
    }
 
    #SSL
    server {
        listen 443;
        server_name localhost;
        ssl on;
        root html;
        index index.html index.htm;
        ssl_certificate   cert/214897222470878.pem;
        ssl_certificate_key  cert/214897222470878.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 / {
    #反向代理
        proxy_pass http://127.0.0.1:8082;
            root html;
            index index.html index.htm;
        }
    #文件服务器
        location /files/ {
            root  /home/law/upload/;
            autoindex on;
           
    }

推荐阅读