部署 – 部署两个不同的Play!应用程序在同一主机名上

我使用Play Framework开发了2个应用程序,访问不同的信息,因此将其合并为单个应用程序没有意义.

现在我需要在同一个主机名上部署这两个应用程序,每个应用程序都在一个单独的子文件夹(URI)中,例如:
example.com/payment/
example.com/cms/

我遇到路线问题.我配置了一个Nginx webserver作为反向代理.它按预期交付第一页.

但是一旦我点击任何东西,而不是转到/ cms / Application / index,它会链接回/ Application / index(没有/ cms /).

恕我直言我相信我需要在所有路径上更改我的路由文件,hardcoding / cms /,但这似乎是一个糟糕的方法,因为如果我需要在另一个URI上部署APP,我将需要再次更改路由.

在同一主机名上部署两个应用程序的最佳方法是什么?

----- Nginx.conf -----
...
...
...

    location /cms {
      proxy_pass      http://localhost:9001/;

      proxy_redirect          off;
      proxy_set_header        Host            $host;
      proxy_set_header        X-Real-IP       $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /payment {
      proxy_pass      http://localhost:9002/;

      proxy_redirect          off;
      proxy_set_header        Host            $host;
      proxy_set_header        X-Real-IP       $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    }

...
...
...
----- Nginx.conf -----
最佳答案
如果您查看Google网上论坛上的this thread,您会看到首选方法是上下文路径.

建议使用引导作业以下列方式设置每个应用程序的上下文

Play.ctxPath="/project1";
Router.detectChanges(Play.ctxPath);

所以你的代码就是

Play.ctxPath="/cms";
Router.detectChanges(Play.ctxPath);

等等

相关文章

Nginx (engine x) 是一个高性能的HTTP和反向代理服务,也是一...
本地项目配置 1 复制 luffy/settings/dev.py为prop.py 修改l...
nginx不仅可以隐藏版本信息,还支持自定义web服务器信息 先看...
一 、此次漏洞分析 1 nginx HTTP/2漏洞 [nginx-announce] ng...
###进入nginx 目录cd /usr/local/nginx###递归显示 2 级目录...
在cmd命令窗口输入下面命令进行查看 tasklist /fi "ima...