【问题标题】:ember, nginx, reverse proxy余烬,nginx,反向代理
【发布时间】:2017-08-19 02:51:53
【问题描述】:

我已将我的应用程序部署到位于以下位置的文件服务器: http://example.com/my-team/my-app

我们希望我们的应用面向: http://amazingapp.com

到目前为止,这就是我在 nginx 上所拥有的

server {
  listen 80;
  server_name http://amazingapp.com;
  location / {
      proxy_pass http://example.com/my-team/my-app/;
  }
}

这适用于初始 http://amazingapp.com,但任何后续请求 http://amazingapp.com/post/1/comment/2 都会导致 404

大多数 ember 部署示例都使用 try_files $uri $uri/ index.html 从与 Web 服务器相同的位置提供文件,所以我不相信我能够走这条路?

我尝试在该位置使用正则表达式,但这需要 proxy_pass 具有参数。

如果您能指出我正确的方向,将不胜感激。 提前致谢!

【问题讨论】:

    标签: nginx ember.js reverse-proxy nginx-location


    【解决方案1】:

    考虑下面的配置

    server {
      listen 80;
      server_name http://amazingapp.com;
      location / {
          proxy_pass http://example.com/my-team/my-app;
      }
    }
    

    当您访问http://amazingapp.com/abc 时,您的位置/ 将删除abc 并附加到proxy_pass。将您的网址设为 http://example.com/my-team/my-appabc. Fix is quite simple, just add a trailing/` 到您的 proxy_pass

    server {
      listen 80;
      server_name http://amazingapp.com;
      location / {
          proxy_pass http://example.com/my-team/my-app/;
      }
    }
    

    【讨论】:

    • 抱歉,proxy_pass 上确实有“/”。没有'/'资源甚至没有加载。将更新我的示例。
    • 不幸的是,除了初始请求之外,我仍然得到 404。
    • 另外我希望你没有server_name 作为amazingapp.com 而不是http://amazingapp.com。现在才看到那个错误?你也可以做一个curl -v http://amazingapp.com/post/1/comment/2 看看是否有什么有趣的东西吗?另一件事请发布您的 nginx 访问+错误日志,其中显示有关错误的详细信息
    • 我需要 proxy_pass 留在 /example.com/my-team/my-app/ 并让 Web 应用处理 /abc/ 的路由
    • @imahungry,我明白这一点。但我需要知道目前出了什么问题。 curl -v 和 nginx 日志会有所帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-05
    • 2011-08-09
    • 2013-02-18
    • 2021-04-08
    • 2019-03-19
    • 2016-07-22
    • 1970-01-01
    相关资源
    最近更新 更多