Skip to content

Commit 8ce2410

Browse files
authored
Optimize nginx configuration (#124)
* Optimize nginx configuration - Use aio - Use HTTP/1.1 and keepalive on backend proxy connections
1 parent f5c2f27 commit 8ce2410

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

custom-nginx-reverse-proxy.conf

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
worker_processes 1;
1+
worker_processes auto;
22

3-
events { worker_connections 1024; }
3+
events {
4+
accept_mutex on;
5+
multi_accept on;
6+
worker_connections 512;
7+
}
48

59
http {
610
include mime.types;
711
server_names_hash_bucket_size 128;
812
sendfile on;
9-
10-
proxy_buffers 8 1024k;
13+
14+
proxy_buffers 8 1024k;
1115
proxy_buffer_size 1024k;
16+
aio on;
17+
directio 4m;
18+
tcp_nopush on;
19+
tcp_nodelay on;
1220

1321
upstream eae {
1422
server 10.200.10.1:8081;
23+
keepalive 20;
24+
keepalive_requests 50;
25+
keepalive_timeout 60s;
1526
}
1627

1728
upstream platform {
@@ -25,11 +36,17 @@ http {
2536
upstream brokers_ws {
2637
server 10.200.10.1:8690;
2738
server 10.200.10.1:8790;
39+
keepalive 20;
40+
keepalive_requests 50;
41+
keepalive_timeout 60s;
2842
}
2943

3044
upstream brokers_http {
3145
server 10.200.10.1:8691;
3246
server 10.200.10.1:8791;
47+
keepalive 20;
48+
keepalive_requests 50;
49+
keepalive_timeout 60s;
3350
}
3451

3552
upstream storage_http {
@@ -90,18 +107,24 @@ http {
90107
add_header X-debug "/api/v1/streams";
91108
proxy_pass http://storage_http;
92109
proxy_read_timeout 240s;
110+
proxy_http_version 1.1;
111+
proxy_set_header Connection "";
93112
}
94113

95114
# Data Volume endpoint
96115
location /api/v1/volume {
97116
add_header X-debug "/api/v1/volume";
98117
proxy_pass http://brokers_http;
99118
proxy_read_timeout 240s;
119+
proxy_http_version 1.1;
120+
proxy_set_header Connection "";
100121
}
101122

102123
# Network explorer
103124
location /network-explorer/ {
104125
proxy_pass http://network_explorer$request_uri;
126+
proxy_http_version 1.1;
127+
proxy_set_header Connection "";
105128
}
106129

107130
### API ENDPOINTS PROXIED TO ENGINE-AND-EDITOR ###
@@ -124,14 +147,17 @@ http {
124147
proxy_set_header X-Forwarded-Port $server_port;
125148
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
126149
proxy_set_header X-Request-URI $request_uri;
127-
150+
proxy_set_header Connection "";
151+
proxy_http_version 1.1;
128152
proxy_pass http://eae$uri;
129153
}
130154

131155
### Utility paths proxied to the Ethereum nodes in the docker stack. Useful if SSL is terminated at nginx ###
132156

133157
location /mainchain-rpc/http/ {
134158
proxy_pass http://mainchain_rpc_http/;
159+
proxy_http_version 1.1;
160+
proxy_set_header Connection "";
135161
}
136162

137163
location /mainchain-rpc/ws/ {
@@ -145,6 +171,8 @@ http {
145171

146172
location /sidechain-rpc/http/ {
147173
proxy_pass http://sidechain_rpc_http/;
174+
proxy_http_version 1.1;
175+
proxy_set_header Connection "";
148176
}
149177

150178
location /sidechain-rpc/ws/ {
@@ -178,6 +206,8 @@ http {
178206
proxy_set_header X-Real-IP $remote_addr;
179207
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
180208
proxy_set_header X-Forwarded-Host $server_name;
209+
proxy_http_version 1.1;
210+
proxy_set_header Connection "";
181211
}
182212

183213
}

0 commit comments

Comments
 (0)