upstream rails-server { server 127.0.0.1:3000 fail_timeout=0; } server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /app/public; client_max_body_size 16m; location / { try_files $uri $uri/index.html $uri.html @rails; } location ~ ^/assets/ { expires 1y; add_header Cache-Control public; add_header ETag ""; break; } location @rails { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_pass http://rails-server; proxy_redirect off; error_page 500 502 504 /500.html; # Rails error pages } }