upstream app_server { # for UNIX domain socket setups: server unix:/tmp/.sock fail_timeout=0; # for TCP setups, point these to your backend servers # server 127.0.0.1:8080 fail_timeout=0; # server 192.168.0.8:8080 fail_timeout=0; # server 192.168.0.9:8080 fail_timeout=0; } server { listen 80; server_name www.mydomain.it mydomain.it; location / { proxy_pass http://app_server/it; } } server { listen 80 default deferred; client_max_body_size 4G; server_name _; keepalive_timeout 5; # path for static files root /home/app_user/current/my_app/public/; # Prefer to serve static files directly from nginx to avoid unnecessary try_files $uri/index.html $uri.html $uri @app; location @app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server; } # Rails error pages error_page 500 502 503 504 /500.html; location = /500.html { root /path/to/app/current/public; } }