Files
kjvstudy.org/nginx.conf
T
kennethreitz d630e629bd Add nginx to docker-compose setup
- nginx.conf: docker-compose version (uses 'web:8001')
- nginx-prod.conf: production version (uses '127.0.0.1:8001')
- Separate nginx service in docker-compose
- uvicorn runs on port 8001, nginx exposes 8000

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 02:01:00 -05:00

98 lines
2.6 KiB
Nginx Configuration File

worker_processes auto;
error_log /dev/stderr warn;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
use epoll;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging
access_log /dev/stdout combined;
# Request buffering - absorb slow clients
client_body_buffer_size 128k;
client_max_body_size 10m;
client_body_timeout 60s;
client_header_timeout 60s;
# Response buffering
proxy_buffering on;
proxy_buffer_size 4k;
proxy_buffers 8 32k;
proxy_busy_buffers_size 64k;
# Keepalive
keepalive_timeout 65;
keepalive_requests 1000;
# Compression
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;
# Upstream - uvicorn (use 'web' for docker-compose, '127.0.0.1' for single container)
upstream app {
server web:8001;
keepalive 32;
}
server {
listen 8000;
server_name _;
# Static files - serve directly with caching
location /static/ {
alias /app/kjvstudy_org/static/;
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
# Service worker - special cache headers
location = /sw.js {
proxy_pass http://app;
proxy_http_version 1.1;
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;
add_header Cache-Control "no-cache";
}
# All other requests - proxy to uvicorn
location / {
proxy_pass http://app;
proxy_http_version 1.1;
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;
proxy_set_header Connection "";
# Request buffering
proxy_request_buffering on;
# Timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# Health check endpoint - bypass buffering for speed
location = /api/health {
proxy_pass http://app;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_buffering off;
}
}
}