-
Notifications
You must be signed in to change notification settings - Fork 923
/
Copy pathnginx.conf
66 lines (52 loc) · 2.9 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
66
# This directive sets the number of worker processes to automatically adjust based on the number of CPU cores available.
# This is useful for optimizing performance without manually specifying the number of processes.
worker_processes auto;
# This directive sets the maximum number of open file descriptors for each worker process.
# Increasing this limit can help handle a large number of simultaneous connections.
worker_rlimit_nofile 500000;
events {
# This tells Nginx to use the epoll method for managing connections on Linux.
# epoll is efficient for handling a large number of simultaneous connections.
# More options here: https://nginx.org/en/docs/events.html
use epoll;
# This sets the maximum number of connections that each worker process can handle.
# A higher number allows more simultaneous connections.
# More about here: https://www.nginx.com/blog/tuning-nginx/
worker_connections 1024;
}
http {
# This disables the access log, which can improve performance by not writing every request to a log file.
access_log off;
# This redirects error logs to /dev/null, effectively discarding them, except for emergency level messages.
# This can be risky but may improve performance by avoiding disk writes for errors.
error_log /dev/null emerg;
upstream api {
# These lines define a group of servers that can handle requests to the api upstream.
# Requests will be load-balanced between these servers.
server 127.0.0.1:8080;
server 127.0.0.1:8081;
# Sets the number of idle keepalive connections to upstream servers that are preserved.
# This can improve performance by reusing connections for multiple requests.
keepalive 250;
}
server {
# Configures the server to listen on port 9999 for incoming connections.
listen 9999;
# This block defines how to respond to requests for the root URL (/).
# Inside this block, several directives configure how to proxy these requests to the upstream api
location / {
# Disables buffering of responses from the proxied server, which can reduce latency for streaming or real-time applications.
proxy_buffering off;
# Clears the Connection header before forwarding the request to the proxied server.
proxy_set_header Connection "";
# Sets the HTTP version to 1.1 for requests to the proxied server.
proxy_http_version 1.1;
# Clears the Keep-Alive header before forwarding the request.
proxy_set_header Keep-Alive "";
# Sets the Proxy-Connection header to keep-alive to maintain a persistent connection to the proxied server.
proxy_set_header Proxy-Connection "keep-alive";
# Specifies that the request should be forwarded to the api upstream group defined earlier.
proxy_pass http://api;
}
}
}