Skip to content

Instantly share code, notes, and snippets.

@renomureza
Last active November 4, 2023 04:13
Show Gist options
  • Save renomureza/250c4e623e3b739334acf64a6bfeaf9a to your computer and use it in GitHub Desktop.
Save renomureza/250c4e623e3b739334acf64a6bfeaf9a to your computer and use it in GitHub Desktop.
Nginx Config for Serving "out" Folder Nextjs (next export)
# /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;
}
}
@kamal-hossain
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment