首页 > 解决方案 > Nginx 负载均衡器不加载 React 站点

问题描述

我有以下网站,它是一个 React 构建的网站。我有一个带有两个后端服务器的 nginx 负载平衡站点。各个服务器运行良好,但是当在负载平衡器后面时,站点很少加载并且查看浏览器开发工具时会出现大量 404 Not Found 错误:

https://junoscan.skynetexplorers.com

我不明白为什么网站不加载。有时浏览器会开始正常工作。例如,目前 Brave Browser 无法在我的桌面上运行,但开始在我的手机上运行。怎么了?如何解决此行为?

##
# Set Rate Limiting (DDoS protection)
##

        limit_req_zone $binary_remote_addr zone=req_zone:10m rate=5r/s;


# This is the internal server behind the proxy
        upstream bdipper_node {
          least_conn;

          server cluster.provider-0.prod.sjc1.akash.pub:31375;
          server cluster.provider-2.prod.ewr1.akash.pub:31639;
        }

        map $http_upgrade $connection_upgrade {
          default upgrade;
          '' close;
        }

# This is the public facing listening server AND configures SSL for the website
        server {

          root /_next/static/chunks;
          sendfile on;
          tcp_nopush on;
          sendfile_max_chunk 1m;
          tcp_nodelay on;
          keepalive_timeout 65;

          listen 443 ssl;

          location / {

            limit_req zone=req_zone burst=20 nodelay;

            proxy_pass http://bdipper_node/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $host:443;
          }
        }

# This redirect http to https
        server  {
          listen 80 ;
          return 301 https://$host$request_uri;
        }

标签: reactjsnginxload-balancing

解决方案


推荐阅读