Last active
November 4, 2023 04:13
-
-
Save renomureza/250c4e623e3b739334acf64a6bfeaf9a to your computer and use it in GitHub Desktop.
Nginx Config for Serving "out" Folder Nextjs (next export)
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
# /etc/nginx/sites-available/example.com | |
server { | |
listen 80; | |
listen [::]:80; | |
# path to out folder | |
root /var/www/out; | |
index index.html index.htm index.nginx-debian.html; | |
# server_name www.example.com example.com | |
server_name _; | |
error_page 404 /404/index.html; | |
location / { | |
# as directory, then fall back to displaying a 404. | |
try_files $uri $uri/ =404; | |
} | |
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg)$ { | |
expires 365d; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for sharing.
little side note is, don't keep your project at
/root
, then nginx will not have default access to it. Keep your project at/var
instead.