首页 > 解决方案 > NGINX 子目录后面的 ReactJS

问题描述

我有一个 ReactJS 应用程序正在运行,例如:192.168.0.111:12345

我有 NGINX 代理,我希望https://subdomain.domain.com/reactapp正确重定向到 192.168.0.111:12345 并将所有其他 URI 部分传递给它,除了 reactapp 字符串。

例如:

https://subdomain.domain.com/reactapp/home -> 192.168.0.111:12345/home

https://subdomain.domain.com/reactapp/statis/js/bundle.js -> 192.168.0.111:12345/static/js/bundle.js

我怎样才能配置 NGINX 像这样工作?

我试过这个:

location ~ ^/(reactapp/(.*)|(reactapp))$ {
  proxy_pass http://192.168.0.111:12345/$1;
}

标签: reactjsnginx

解决方案


推荐阅读