开发者社区 问答 正文

nginx 反向代理设置好后 请求不到数据。? 400 报错

nginx 反向代理设置好后 请求不到数据。? 400 报错

nginx 反向代理设置好了     页面是通过  npm start 生成的一个临时页面 http://localhost:8080   我请求不到接口数据 请问IT界精英们我该怎么办?

展开
收起
爱吃鱼的程序员 2020-06-04 11:51:59 1412 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    没log,没代码,你问啥?
    你去把《提问的智慧》抄十遍

    ######


    user  root;
    worker_processes  auto;

    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    #pid        logs/nginx.pid;

    events {
        worker_connections  10240;
    }

    http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
        client_max_body_size 0;
        client_body_temp_path /data/nginx-temp;

        gzip on;
        gzip_min_length 1k;
        gzip_buffers 4 16k;
        #gzip_http_version 1.0;
        gzip_comp_level 5;
        gzip_types text/plain application/json application/x-protobuf text/css application/x-javascript text/javascript;
        gzip_vary off;

        upstream app_backend {
                    server 172.18.26.253:50217 weight=8  max_fails=3 fail_timeout=5s;
                    server 172.18.26.254:50217 weight=2  max_fails=3 fail_timeout=5s; 
                    keepalive 90;
           }
           
        upstream opendoor_backend {
                    server 172.18.26.253:50218 weight=8  max_fails=3 fail_timeout=5s;
                    server 172.18.26.254:50218 weight=2  max_fails=3 fail_timeout=5s; 
                    keepalive 90;
           }
           
        #django
        upstream manage_backend {
                    server 172.18.26.253:50223 weight=8  max_fails=3 fail_timeout=5s;
                    server 172.18.26.254:50223 weight=2  max_fails=3 fail_timeout=5s; 
                    keepalive 90;
           }
        
        #web produce
        server {
            listen       0:80;
            server_name  app.xiaoxiaowo.com;
        auth_basic "auth";
        auth_basic_user_file /usr/local/nginx/conf/htpasswd;
                    
            location / {
                proxy_pass  http://app_backend;
                #proxy_set_header  Connection "keep-alive";
                proxy_set_header  Connection "";
                proxy_http_version 1.1;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
            }
            
            location /download/ {
            root /data/file;
        }
            
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }
        
        #file server
        #server
        #{
            #autoindex on;
            #listen 8080;
            #auth_basic "auth";
            #auth_basic_user_file /usr/local/nginx/conf/htpasswd;
            #dav_methods PUT;
            #location /download {
                    #root /data/file;
                #}    
        #}
        
        #manage produce
        server {
            listen       0:80;
            server_name  manage.xiaoxiaowo.com;
        auth_basic "auth";
        auth_basic_user_file /usr/local/nginx/conf/htpasswd;

            location / {
                proxy_pass  http://manage_backend;
                proxy_set_header  Connection "";
                proxy_http_version 1.1;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
            }
            
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }
        
        #opendoor produce
        server {
            listen       0:80;
            server_name  opendoor.xiaoxiaowo.com;
        auth_basic "auth";
        auth_basic_user_file /usr/local/nginx/conf/htpasswd;

            location / {
                proxy_pass  http://opendoor_backend;
                proxy_set_header  Connection "";
                proxy_http_version 1.1;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
            }
            
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }
    }
     

    正好昨天搞了个,给你看看

    ######

      

    大神  nginx配置好了  页面上请求不到数据  请赐教。  谢谢了

    ######

    啃爹,你启动的端口是80,访问使用 8080,怎么可以。。

    http://localhost:8080 

    listen 80

     

    ######

    我是小白。    http://localhost:8080   这个是写在哪里    不是很懂

    ######

    页面是通过 npm start 临时生成的一个页面   http://localhost:9800/#fillout     这个也不是很懂它的机制  我在这个上面怎么弄 都是请求不到数据的 哎。

    ######

     

    那还是去看看书吧,这个教学的成本太高。。。呵呵

    ######

    嗯嗯  谢谢了。   大神

    2020-06-04 16:40:46
    赞同 展开评论