核心科技:在nginx.conf里写两个location ,后端请求都加上/gateway。
注意点:1、路由中的/要和下面的示例一模一样
2、如果后端是跑在docker里的,后端转发的地址要用公网ip,因为docker是虚拟的ip
配置示例如下:
#HTTPS server
server {
listen 443 ssl;
server_name wx.ygiot.fun;
ssl_certificate cert/wx.ygiot.fun.pem;
ssl_certificate_key cert/wx.ygiot.fun.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
location /gateway {
proxy_pass http://47.106.222.153:8080/;
}
}