Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to properly set up Play Framework with Nginx as the front-end HTTP server on Amazon AMI.

I am a bit confused by the official documentation set out by Play. Are they suggesting that you run

start -Dhttp.port=9000

and then configure Nginx to reroute to port 9000 in order to properly serve up my app? I feel like having a dedicated user just to run the start command is a waste, isn't there a better way to do this?

I would really appreciate some basic strategies for best practices for a production Play Framework web app.

share|improve this question

The reason I use a dedicated user for this is so that I can put a number of different environments on a single machine, they are all kept from treading on each other by the separate user id. For example we have an app called "d1" which we have to put into several environments so we have a user for each environment:

d1test d1development d1nightly

For the nightly build the nginx.conf looks like:

upstream d1nightly {

 server {
  listen 443 ssl;
  ssl_certificate      /etc/ssl/certs/cert.pem;
  ssl_certificate_key    /etc/ssl/private/key.pem;
  ssl_session_timeout 5m;
  ssl_protocols SSLv3 TLSv1;
  ssl_ciphers HIGH:!ADH:!MD5;
  ssl_prefer_server_ciphers on;
  location /500x.html {
    alias /usr/share/nginx/html/500x.html;

  location / {
   proxy_set_header Host $http_host;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-Proto https;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_redirect http:// https://;
   add_header Pragma "no-cache";
   proxy_pass http://d1nightly;
   error_page 500 502 503 504 /500x.html;

Now when we go to we get the nightly release.

We pay a fixed rate per VM per hour rather than for CPU time so it we get more value for money with this combination by packing 3 or 4 environments onto a single machine during our testing.

For starting the play applications, I've got a really basic shell script function:

function startPlayAppd1 {
        #start a d1 play app with appropriate system properties
        nohup ${base_directory}/${app}-latest-${jvm}/${snapshot_name}/start \
                       -Dhttp.port=${listen_port}                                             \
             ${env_name}                                                 \
                       -Dlogger.file=${logger_file}                                           \
             ${session_secure}                                     \
                       -Dga.domain=${ga_domain}                                               \
             ${preferIPv4Stack}                          \
             ${jmx_port}                        \
             ${jmx_remote_authenticate} \
             ${javaxDebugLevel}                                   \
                > ${listen_port}.nohup 2>&1 &
        sleep 5

The other advantage of an environment per user is the flexibility it creates.

As you can see various system properties have been added, for example to enable JMX so our monitoring tools can observe the play applications.

This is one solution which has worked well for our use cases.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.