server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; sendfile off; root /srv/http/ctf; index index.html index.htm; server_name localhost; error_page 404 /index.html; # location / { # try_files $uri $uri/ =404; # } # Put all the pages here so Angular doesn't fail. location ~^/(about|chat|help|learn|login|logout|profile|register|scoreboard|settings|team|forgot)$ { default_type text/html; try_files /index.html /index.html; } location ~^/admin/(problems|settings|stats|teams)$ { default_type text/html; try_files /index.html /index.html; } location ~^/(profile|team|forgot)/(.*)$ { default_type text/html; try_files /index.html /index.html; } location ~ /static { root /srv/http/static; } location ~ /api { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost:8000; proxy_redirect off; } }