mirror of
https://github.com/kennethreitz/kennethreitz.org.git
synced 2026-06-05 22:50:17 +00:00
aa699211ee
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
76 lines
2.2 KiB
Nginx Configuration File
76 lines
2.2 KiB
Nginx Configuration File
worker_processes auto;
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
sendfile on;
|
|
tcp_nopush on;
|
|
tcp_nodelay on;
|
|
keepalive_timeout 65;
|
|
|
|
# Gzip compression
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_comp_level 5;
|
|
gzip_types text/plain text/css text/xml text/javascript
|
|
application/json application/javascript application/xml
|
|
application/rss+xml application/atom+xml image/svg+xml;
|
|
|
|
# Request buffering (absorb full request before forwarding)
|
|
proxy_request_buffering on;
|
|
proxy_buffering on;
|
|
proxy_buffer_size 16k;
|
|
proxy_buffers 8 32k;
|
|
|
|
# Static file cache
|
|
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=static_cache:10m max_size=500m inactive=7d;
|
|
|
|
server {
|
|
listen 8000;
|
|
|
|
# Static assets — serve directly from disk
|
|
location /static/ {
|
|
alias /app/tuftecms/static/;
|
|
expires 7d;
|
|
add_header Cache-Control "public, max-age=604800";
|
|
access_log off;
|
|
}
|
|
|
|
# Photography images — serve directly from disk (images only)
|
|
location ~ ^/photography/(.+\.(jpg|jpeg|png|gif|webp|svg))$ {
|
|
alias /app/data/photography/$1;
|
|
expires 7d;
|
|
add_header Cache-Control "public, max-age=604800";
|
|
access_log off;
|
|
}
|
|
|
|
# Legacy images
|
|
location /static/images/legacy/ {
|
|
alias /app/tuftecms/static/images/legacy/;
|
|
expires 7d;
|
|
add_header Cache-Control "public, max-age=604800";
|
|
access_log off;
|
|
}
|
|
|
|
# Everything else — proxy to Granian with caching for images
|
|
location / {
|
|
proxy_pass http://127.0.0.1:8001;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
# Cache proxied image responses
|
|
proxy_cache static_cache;
|
|
proxy_cache_valid 200 7d;
|
|
proxy_cache_use_stale error timeout updating;
|
|
add_header X-Cache-Status $upstream_cache_status;
|
|
}
|
|
}
|
|
}
|