Code Monkey home page Code Monkey logo

Comments (2)

colawithsauce avatar colawithsauce commented on May 26, 2024 2

刚刚解决了这个问题,希望能有所帮助:
按 f12 查看网络情况,可以看到访问 API 会返回 502 错误

查阅 nginx 的Log可知,是上游返回了过大的 header:
image

查看项目根目录下的: docker/nginx.conf.example

server {
  gzip on;
  listen       80;
  listen  [::]:80;
  server_name  localhost;

  location / {
    root      /usr/share/nginx/html;
    index     index.html;
    try_files $uri $uri/ /index.html;
  }

  location @rewrites {
    rewrite ^(.*)$ /index.html last;
  }

  location /api/ {
    proxy_buffers           16 32k;
    proxy_buffer_size       128k;
    proxy_busy_buffers_size 128k;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $remote_addr;
    proxy_set_header        X-Forwarded-Host $remote_addr;
    proxy_set_header        X-NginX-Proxy true;
    proxy_pass              http://localhost:3000/;
  }
}

其中 /api 写了 proxy_buffers之类的参数,所以我们只需要将这些参数统统复制到 host 机器上面的 nginx 就好了,如下:

        # .......
        location / {
                proxy_pass http://localhost:1234/;

                proxy_buffers           16 32k;
                proxy_buffer_size       128k;
                proxy_busy_buffers_size 128k;

                proxy_set_header        Host $host;
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_set_header        X-Forwarded-For $remote_addr;
                proxy_set_header        X-Forwarded-Host $remote_addr;
                proxy_set_header        X-NginX-Proxy true;

                # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        # .......

最后再在host机器上面执行:sudo nginx -s reload

from yesplaymusic.

450816775 avatar 450816775 commented on May 26, 2024

非常感谢你的帮助!!

from yesplaymusic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.