开发者

Deploying two different Play! applications on the same hostname

I have developed 2 applications with Play Framework, accessing different information, so it does not make sense to merge then as a single app.

Now I need to deploy both apps on the same hostname, each one in a separate sub-folder (URI), for example: example.com/payment/ example.com/cms/

And I am having problems with r开发者_StackOverflow中文版outes. I configured a nginx webserver to work as reverse proxy. It deliveries first page as expected.

But once I click anything, instead of going to /cms/Application/index it links back to /Application/index (without /cms/).

IMHO I believe I need change my routes file, hardcoding /cms/ on all paths, but it seems a bad approach because if I need to deploy the APP on another URI I will need to change routes again.

What is the best way to deploy two apps on the same hostname?

----- 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 -----


If you take a look at this thread on the Google Groups, you will see that the preferred approach is to the the context path.

The recommendation is to use a bootstrap job to set the context per application in the following way

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

So your code would be

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

etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜