upstream <%= fetch(:application) %> { server unix:/tmp/unicorn.<%= fetch(:application) %>.sock fail_timeout=0; } server { listen 80; server_name *.<%= fetch(:project_domain) %> <%= fetch(:project_domain) %>; root <%= fetch(:current_path) %>/public; location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; } try_files $uri/index.html $uri @<%= fetch(:application) %>; location @<%= fetch(:application) %> { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://<%= fetch(:application) %>; } error_page 500 502 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; if (-f $document_root/system/maintenance.html) { return 503; } error_page 503 @maintenance; location @maintenance { rewrite ^(.*)$ /system/maintenance.html last; break; } }