-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
47 lines (39 loc) · 1.35 KB
/
nginx.conf
File metadata and controls
47 lines (39 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
events {
worker_connections 1024;
}
http {
# Define rate limit zones
limit_req_zone $binary_remote_addr zone=api_limit:10m rate=5r/s; # 5 requests per second for API
limit_req_zone $binary_remote_addr zone=frontend_limit:10m rate=10r/s; # 10 requests per second for frontend
upstream frontend {
server frontend:3000;
}
upstream backend {
server backend:5000;
}
server {
listen 80;
# API requests with rate limiting
location /api/v1/ {
# Apply rate limiting with bursting
limit_req zone=api_limit burst=10 nodelay;
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# Frontend requests with rate limiting
location / {
# Apply rate limiting with bursting
limit_req zone=frontend_limit burst=20 nodelay;
proxy_pass http://frontend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}