server { listen 80; server_name app.example.com; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 443; server_name app.example.com; ssl on; ssl_certificate /etc/nginx/ssl/ssl.crt; ssl_certificate_key /etc/nginx/ssl/ssl.key; location = /favicon.ico { root /home/ubuntu/app/bundle/static; access_log off; expires 1w; } location ~* "^/[a-z0-9]{40}\.(css|js)$" { root /home/ubuntu/app/bundle/static_cacheable; access_log off; expires max; } location / { proxy_pass http://localhost:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; } }