upstream <%= application_name %> {

server unix:///var/apps/<%= application_name %>/shared/sockets/<%= application_name %>.sock;

}

server {

listen 80;
server_name <%= name %>.<%= application_name %>.co.nz;
root /var/apps/<%= application_name %>/current/public;

location / {
  proxy_pass http://<%= application_name %>; # match the name of upstream directive which is defined above
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location ~* ^/assets/ {
  # Per RFC2616 - 1 year maximum expiry
  expires 1y;
  add_header Cache-Control public;

  # Some browsers still send conditional-GET requests if there's a
  # Last-Modified header or an ETag header even if they haven't
  # reached the expiry date sent in the Expires header.
  add_header Last-Modified "";
  add_header ETag "";
  break;
}

}