upstream tracd-<%= application %> { server 127.0.0.1:9000; } server { listen 80; server_name <%= tracd_vhost_domain %>; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect false; if ($request_filename !~ /<%= application %> ) { rewrite (.*) http://<%= tracd_vhost_domain %>/<%= application %>$1 permanent; } proxy_pass http://tracd-<%= application %>; break; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }