Setup multiple Play 2.1 applications with nginx using different subdirectory for each application.
App1 running on 127.0.0.1:4000
should be accessible under 127.0.0.1/dev
App2 running on 127.0.0.1:5000
should be accessible under 127.0.0.1/test
nginx.conf
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
upstream app1 {
server 127.0.0.1:4000;
}
upstream app2 {
server 127.0.0.1:5000;
}
server {
listen 80;
server_name localhost;
location /dev {
rewrite /(.*) /$1 break;
proxy_pass http://app1;
}
location /test {
rewrite /(.*) /$1 break;
proxy_pass http://app2;
}
}
}
App1 - application.conf
application.context=/dev
App2 - application.conf
application.context=/test
With this configuration I can access both applications, but only html code is loaded. All static files (css, js, images) aren't loaded.
I think this is caching problem. I've tried with different nginx parameters, without luck. If I request the site for the first time the browser responds (for css
and js
files, e.g. 127.0.0.1/dev/assets/stylesheets/main.css
) with status 200
but without content - Content-Length: 0
. For the next time it responds with 304
, still without content.
I'm not sure if this is nginx
or Play 2.1
configuration problem.
I will appreciate any help.
Use local domains like http://test.loc/
and http://dev.loc
instead of relying on subfolders. Although application.context
should work I saw many posts complaining that they don't...
What's more using local domains is more similar to the final - production enviroment, so it's just easier to debug some url depended things, like ie. cookies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With