设备环境: 虚拟机、反向代理+公网IP
BUG现象:我通过把本地的飞牛os和一台具有公网IP的服务进行主网,然后通过nginx转发,实现公网访问。其中假如公网 域名:https://exp.com 转发 到内网 https://10.10.10.1:8001 ,此时nginx监听的是443端口,经过测试在手机端和PC端通过浏览器都是可以正常访问的,但是手机端的APP则无法登录
具体解决:经过测试,手机端APP的IP识别似乎要携带对应的端口,也就是必须在nginx里监听8001端口,组成域名https://exp.com:8001,转发 到内网 https://10.10.10.1:8001,才可以正确在手机APP里登录
建议:https://exp.com:8001这种访问方式实在是太不优雅了,暴露端口,建议手机端也可以直接用https://exp.com进行登录
服务器上的nginx配置
server {
listen 443 ssl http2;
# 发现问题后进行的端口补充
listen 8001 ssl http2;
server_name fnos.huzhihao.top;
# SSL证书文件路径
ssl_certificate /etc/certs/exp.top.cer;
ssl_certificate_key /etc/certs/exp.top.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
# HSTS 头
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
location / {
proxy_pass https://10.10.10.1:8001;
proxy_http_version 1.1;
# 支持 WebSocket
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
出现频率: 必现
联系方式:群fnOS251 不知为何 |