Created
July 1, 2020 10:39
NGINX server configuration for nextjs static generated site.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name localhost; | |
root /usr/share/nginx/html; | |
location ~ /.+ { | |
try_files $uri $uri.html $uri =404; | |
} | |
location / { | |
index index.html index.htm; | |
} | |
error_page 404 /_errors/404.html; | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
} |
+1 works great, thanks for the gist
You saved my life! ♥
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thx man :) Was looking for exactly this (location dependant try_files + error 404 on not available page)