Skip to content

Instantly share code, notes, and snippets.

@df-a
Created October 12, 2022 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save df-a/a8ca11b77124d88b36e2f7cc65810641 to your computer and use it in GitHub Desktop.
Save df-a/a8ca11b77124d88b36e2f7cc65810641 to your computer and use it in GitHub Desktop.
NGinx Gatsby Config
# found here
# https://raghuvirkasturi.com/yearly-ritual/
worker_processes auto;
user [whatever user you use];
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
keepalive_timeout 15;
autoindex off;
server_tokens off;
port_in_redirect off;
sendfile off;
tcp_nopush on;
tcp_nodelay on;
client_max_body_size 64k;
client_header_buffer_size 16k;
large_client_header_buffers 4 16k;
## Cache open FD
open_file_cache max=10000 inactive=3600s;
open_file_cache_valid 7200s;
open_file_cache_min_uses 2;
## Gzipping is an easy way to reduce page weight
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_types [some types]
gzip_buffers 16 8k;
access_log /var/log/access.log;
error_log /var/log/error.log;
server {
listen 80;
root [wherever your blog is];
index index.html;
autoindex off;
charset urtf-8;
error_page 404 /404.html;
location ~* \.(html)$ {
add_header Cache-Control "no-store";
expires off;
}
location ~* \.([all the extensions you want to cache])$ {
add_header Cache-Control "public";
expires +1y;
}
rewrite ^([^.\?]*[^/])$ $1/ permanent
try_files $uri $uri/ $uri/index.html =404;
[some SSL stuff]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment