【记录】解决uni-app 用nginx反向代理出现Invalid Host header问题
之前解决过一次,后来给忘记了,今天又遇到这个问题,现记录一下
修改uni-app的manifest.json文件 - 》源码视图
添加以下代码:
"disableHostCheck" : true //解决127.0.0.1指向其他域名时出现"Invalid Host header"问题
VUE项目遇到此问题也类似解决方案(因为uni-app :一款基于vue的跨平台前端框架)
VUE工程解决方案参考:https://blog.csdn.net/Cookysurongbin/article/details/86077241
以下是我的nginx配置,仅供参考
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ # ‘$status $body_bytes_sent "$http_referer" ‘ # ‘"$http_user_agent" "$http_x_forwarded_for"‘; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name test.com; client_max_body_size 1000m; location / { proxy_set_header Host $Host; proxy_set_header X-Forward-For $remote_addr; proxy_pass http://127.0.0.1:9090; } location /propese { proxy_set_header Host $Host; proxy_set_header X-Forward-For $remote_addr; proxy_pass http://127.0.0.1:9100/propese; } location /swagger { proxy_set_header Host $Host; proxy_set_header X-Forward-For $remote_addr; proxy_pass http://127.0.0.1:9100/swagger-ui.html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
希望能帮助大家,更重要的是避免下次采坑!!!
相关推荐
carolAnn 2020-04-14
scaleqiao 2020-10-22
SZStudy 2020-07-04
ssihc0 2020-06-14
某些公司会墙特定网站,如果你有一个可访问的域名和服务器,就可以通过nginx反向代理来来解决这些问题。比如现在我们用mirror.example.com镜像www.baidu.com,以下是详细操作。
byourb 2020-06-05
阳光岛主 2020-06-01
岁月如歌 2020-04-15
Strongding 2020-04-08
ysmh00 2020-03-27
APCDE 2020-02-21
Freshairx 2020-02-19
tinydu 2020-02-12
carolAnn 2020-02-01
liwf 2020-01-13
nginxs 2020-01-05
Caleb0 2019-12-27
Strongding 2019-12-24