feat: add Nginx reverse proxy service with rate limiting to docker-compose configuration
This commit is contained in:
+13
-2
@@ -1,6 +1,17 @@
|
||||
services:
|
||||
erika:
|
||||
build: .
|
||||
ports:
|
||||
- "8606:3000"
|
||||
expose:
|
||||
- "3000"
|
||||
restart: unless-stopped
|
||||
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: erika-nginx
|
||||
ports:
|
||||
- "8606:80"
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
depends_on:
|
||||
- erika
|
||||
restart: unless-stopped
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
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;
|
||||
|
||||
location / {
|
||||
# Apply rate limit: allow burst of up to 10 requests without delay
|
||||
limit_req zone=ratelimit burst=10 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user