Created
October 1, 2023 05:12
-
-
Save dukedorje/01fd7ddbfc8cdac4e02c6105d26ca7fe to your computer and use it in GitHub Desktop.
SvelteKit Nginx config -- nodejs adapter
This file contains hidden or 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
upstream sveltekit-server { | |
server 127.0.0.1:3000; | |
keepalive 8; | |
} | |
server { | |
listen 80; | |
server_name mydomain.com; | |
root /home/deploy/frontend/build/client; | |
location / { | |
try_files $uri $uri/ @sveltekit; | |
} | |
location @sveltekit { | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-NginX-Proxy true; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header X-Sendfile-Type X-Accel-Redirect; | |
proxy_pass http://sveltekit-server; | |
proxy_redirect off; | |
# error_page 502 = @static; | |
} | |
location ^~ /_app/immutable/ { | |
# gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
access_log off; | |
try_files $uri $uri/ @sveltekit; | |
} | |
} |
You can also make the use of immutable
in cache
-add_header Cache-Control public;
+add_header Cache-Control public, immutable;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
repo checked out to /home/deploy/frontend ; ~/ssh/id_rsa.pub added to Github's Deploy keys.
In that directory,
git pull
,pnpm install
,pnpm build
Use something like Cloudflare so you don't have to mess around with Certbot. Unless you want to.