-
Notifications
You must be signed in to change notification settings - Fork 923
/
Copy pathnginx.conf
42 lines (35 loc) · 2.01 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
worker_processes auto; # Auto-detects the number of cores and launches that many worker processes
events {
worker_connections 30000; # Increase if you need to handle more than 1,000 connections simultaneously
use epoll; # Use efficient event model for Linux
multi_accept on; # Accept as many connections as possible when they come in
}
http {
sendfile on; # Allows Nginx to use the sendfile system call to serve static files
tcp_nopush on; # Optimizes the amount of data sent at once
tcp_nodelay on; # Disables Nagle's algorithm to improve network efficiency
keepalive_timeout 0; # Allows persistent connections, which reduces latency for subsequent requests
types_hash_max_size 2048; # Increases the maximum size of the types hash tables
server_tokens off; # Hides Nginx version information from error pages and Server response header field
access_log off;
upstream api {
least_conn; # Sends new requests to the server with the least number of active connections
server localhost:8080; # api01
server localhost:8081; # api02
}
gzip on; # Enables gzip compression to reduce the size of the HTTP response
gzip_comp_level 5; # Sets the level of compression (1 is least, 9 is most)
gzip_min_length 256; # Sets the minimum length of a response that will be gzipped
gzip_proxied any; # Compress data even for clients that are connecting via proxies
gzip_vary on; # Tells proxies to cache both gzipped and regular versions of a resource
server {
listen 9999;
location / {
proxy_pass http://api;
proxy_set_header Host $host; # Passes the original host header to the backend
proxy_set_header X-Real-IP $remote_addr; # Passes the original IP address of the client
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Passes the original "X-Forwarded-For" header
proxy_set_header X-Forwarded-Proto $scheme; # Passes the original scheme of the client
}
}
}