server { listen 80; listen 443 ssl http2; # set path to your project dir set $root_path /root/app; # your domain server_name domain.com; # static content directory root $root_path/public; # proxy to nuxt renderer. location / { proxy_pass http://localhost:3000; } # entry point for API server, if you have one location /api { proxy_pass http://localhost:3001; client_max_body_size 3m; } # entry point for SPA admin page, if you have one location /admin { try_files /admin/index.html =404; } # serve nuxt bundle with max cache life. Only compatible with nuxt 2.*. For 1.*, remove last 'client' from alias location ~^\/_nuxt(.*)$ { alias $root_path/client/.nuxt/dist/client/$1; gzip on; gzip_comp_level 6; gzip_vary on; gzip_types text/css application/json application/javascript text/javascript application/x-font-ttf font/opentype; expires max; } # serve static content location ~* \.(js|jpg|jpeg|txt|png|css|pdf|ico|map)$ { gzip_static on; expires 30d; } # refirect from /path/ to /path rewrite ^/(.*)/$ /$1 permanent; } # redirect for domain aliases server { server_name www.domain.com; return 301 https://$host$request_uri; } # placeholder if user requests your servers' IP. server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; server_name _; location / { try_files $uri =404; } }