zoukankan      html  css  js  c++  java
  • 【记录】解决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;
            }
    
        }
    	
    
    }
    

      

    希望能帮助大家,更重要的是避免下次采坑!!!

  • 相关阅读:
    2016第5周四
    2016第5周三
    2016第5周二
    HTTP2.0那些事
    2016第4周日
    【C语言的日常实践(十二)】命令行参数
    Oracle改变字段类型
    Codeforces Round #269 (Div. 2)
    linux shell 命令
    Codeforces Round #256 (Div. 2) C. Painting Fence 或搜索DP
  • 原文地址:https://www.cnblogs.com/wbl001/p/11772676.html
Copyright © 2011-2022 走看看