Files
erika/nginx.conf
T

48 lines
1.5 KiB
Nginx Configuration File

worker_processes auto;
events {
worker_connections 1024;
}
http {
# Enable logging to see what's happening
error_log /dev/stderr warn;
access_log /dev/stdout;
# Define rate limit zone: 10MB memory, 5 requests per second per IP
limit_req_zone $binary_remote_addr zone=ratelimit:10m rate=5r/s;
server {
listen 80;
# Bypass rate limit for static assets and Next.js internal files
location /_next/ {
proxy_pass http://erika:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
# Apply rate limit to actual page loads and API requests
location / {
# Increased burst to 30 to allow normal page loads that fetch multiple APIs/images
limit_req zone=ratelimit burst=30 nodelay;
# Proxy to the Next.js app
proxy_pass http://erika:3000;
# Next.js often requires HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Forward headers
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;
}
}
}