【问题标题】:Error in Deploying two React apps in nginx在 nginx 中部署两个 React 应用程序时出错
【发布时间】:2021-07-28 00:40:30
【问题描述】:

尝试部署两个 React 应用

server {
listen 80;

#  server_name IPAddress;

  access_log /var/log/nginx/Static.com.access.log;
  error_log /var/log/nginx/Static.com.error.log;
location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
  }
   location /elderly/ {
#    rewrite ^/codify(.*) $1 break;
    proxy_pass http://127.0.0.1:3001;
    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-Proto $scheme;
  }
}

www.IPadress.com 工作正常,但是当我打开 www.IPadress.com/elderly 时它无法工作。

【问题讨论】:

  • “它不工作”可能意味着很多不同的东西。您能否尽可能详细地展示故障模式的示例?

标签: reactjs amazon-web-services nginx npm amazon-ec2


【解决方案1】:

您需要在.env 文件中添加PUBLIC_URL 字段:

PUBLIC_URL=/elderly

【讨论】:

    猜你喜欢
    • 2022-06-29
    • 2019-03-14
    • 1970-01-01
    • 2019-08-21
    • 1970-01-01
    • 2021-05-16
    • 1970-01-01
    • 2013-07-04
    • 2017-09-30
    相关资源
    最近更新 更多