【问题标题】:NGinx not routing between Node.js back-end and React front-endNGinx 不在 Node.js 后端和 React 前端之间路由
【发布时间】:2020-05-15 21:59:04
【问题描述】:

我使用 NGINX 默认配置在 AWS Elastic Beanstalk 上部署了一个带有 Node.js 后端和 React 前端的 Web 应用程序。

upstream nodejs {
    server 127.0.0.1:8081;
    keepalive 256;
}

server {
    listen 8080;

    location / {
        proxy_pass  http://nodejs;
        proxy_set_header   Connection "";
        proxy_http_version 1.1;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    }

gzip on;
gzip_comp_level 4;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
}

我的后端在 8081 端口上运行(使用 Express.js)并且没有收到前端发出的任何调用,即fetch("http:127.0.0.1/api/volatility")

在控制台中我看到GET https://foo-bar.us-east-1.elasticbeanstalk.com:8080/api/volatility net::ERR_CONNECTION_TIMED_OUT

有什么办法可以解决这个问题?

【问题讨论】:

  • 尝试server nodejs:8081;(而不是上游配置中的127.0.0.1

标签: node.js nginx


【解决方案1】:

我的 Elastic Beanstalk 服务没有读取/写入数据库的权限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-10
    • 2020-08-04
    • 1970-01-01
    • 1970-01-01
    • 2021-09-16
    • 2020-04-19
    • 2019-02-13
    • 2021-03-08
    相关资源
    最近更新 更多