Skip to content

Instantly share code, notes, and snippets.

@wolfeidau
Created August 8, 2018 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolfeidau/2c449a9cb09495d8e28fcc5d15f64d7b to your computer and use it in GitHub Desktop.
Save wolfeidau/2c449a9cb09495d8e28fcc5d15f64d7b to your computer and use it in GitHub Desktop.
NGINX configuration used to serve an SPA
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
# rely on X-Forwarded-Proto to redirect to HTTPS
if ($http_x_forwarded_proto = "http") {
return 301 https://$server_name$request_uri;
}
location / {
# serve up index.html for any 404 with the original URI intact
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment