Serving static assets for a single-page-app with nginx Serving static assets for a single-page-app with nginx nginx nginx

Serving static assets for a single-page-app with nginx


I think I figured it out, but It'd be super helpful if someone could verify, as I'm still fairly new to nginx.

location / {  # ...  proxy_set_header       Host 's3.amazonaws.com';  # ...  rewrite ^/(.*) /${S3_BUCKET}/ember/index.html break;  proxy_pass             "https://s3.amazonaws.com/${S3_BUCKET}/ember/index.html";}

Having the Host header is important here, because without it, rewrite will change the URL in the user's browser (which we don't want to do, cause that will more than likely mess with the SPA's routing.