-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnginx.conf
65 lines (57 loc) · 3.23 KB
/
nginx.conf
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
events {
worker_connections 1024; # Maximum number of simultaneous connections
}
# Define the HTTP block to configure the HTTP server
http {
# Include MIME types
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Basic settings
sendfile on; # Enable sendfile for improved performance
tcp_nopush on; # Enable TCP_NOPUSH to send headers in one packet
tcp_nodelay on; # Enable TCP_NODELAY to send data immediately
keepalive_timeout 65; # Timeout for keep-alive connections
types_hash_max_size 2048; # Maximum size of types hash table
# Define an upstream block to group backend servers
# This upstream block is named 'frontend' and points to the frontend service
upstream frontend {
server kenyare-frontend:5173; # Use the 'kenyare-frontend' service name and exposed port
}
# Define an upstream block to group backend servers
# This upstream block is named 'backend' and points to the backend service
upstream backend {
server kenyare-backend:8000; # Use the 'kenyare-backend' service name and exposed port
}
# Define a server block to handle incoming HTTP requests
server {
listen 80; # Listen on port 80 for incoming HTTP requests
# WebSocket support for Vite HMR
location /ws {
proxy_pass http://frontend; # Forward WebSocket requests to the 'frontend' upstream
proxy_http_version 1.1; # Use HTTP/1.1 for WebSocket support
proxy_set_header Upgrade $http_upgrade; # Set the Upgrade header for WebSocket
proxy_set_header Connection "upgrade"; # Set the Connection header for WebSocket
proxy_set_header Host $host; # Preserve the original Host header
}
# Define a location block to handle requests to the root URL
location / {
proxy_pass http://frontend; # Forward requests to the 'frontend' upstream
proxy_http_version 1.1; # Use HTTP/1.1 for persistent connections
proxy_set_header Host $host; # Preserve the original Host header
proxy_set_header X-Real-IP $remote_addr; # Preserve the original client IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Preserve the original X-Forwarded-For header
proxy_set_header X-Forwarded-Proto $scheme; # Preserve the original scheme (http or https)
proxy_read_timeout 600s; # Timeout for reading a response from the proxied server
proxy_connect_timeout 600s; # Timeout for establishing a connection to the proxied server
}
# Define a location block to handle requests to the /api/ URL
location /api/ {
proxy_pass http://backend/; # Forward requests to the 'backend' upstream
proxy_http_version 1.1; # Use HTTP/1.1 for persistent connections
proxy_set_header Host $host; # Preserve the original Host header
proxy_set_header X-Real-IP $remote_addr; # Preserve the original client IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Preserve the original X-Forwarded-For header
proxy_set_header X-Forwarded-Proto $scheme; # Preserve the original scheme (http or https)
}
}
}