install yarn in nginx
# /etc/nginx/sites-available/nextjs-example.willandskill.eu
server {
server_name nextjs-example.willandskill.eu;
access_log /opt/nextjs/logs/access.log;
error_log /opt/nextjs/logs/error.log error;
location /_next/ {
alias /opt/nextjs/project/.next/;
expires 30d;
access_log on;
}
location / {
# reverse proxy for next server
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# we need to remove this 404 handling
# because next's _next folder and own handling
# try_files $uri $uri/ =404;
}
}