yapi 的 nginx 反向代理配置文本
不了解yapi的同学可以百度一下哈,就是一款API管理工具,以下为本人实际配置,亲测可用哈
upstream yapi {
server 127.0.0.1:3000 weight=5;
}
server {
listen 80;
server_name localhost yapi.iamphper.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://yapi;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_http_version 1.1;
}
}
更新一波
开启https并强制跳转
upstream yapi {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name yapi.iamphper.cn;
#重定向方式强制https
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name yapi.iamphper.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
ssl_certificate /www/wwwroot/yapi/Nginx/1_yapi.iamphper.cn_bundle.crt;
ssl_certificate_key /www/wwwroot/yapi/Nginx/2_yapi.iamphper.cn.key;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://yapi;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_http_version 1.1;
}
}
本作品采用《CC 协议》,转载必须注明作者和本文链接
反代的话 刷新一下 又要重新登录
最后我还是用
ip
+端口
了