Skip to content

Commit 901b400

Browse files
authored
Optimize default nginx config (#1040)
Problem: We want to ensure that the default nginx configuration uses the best possible options for performance and stability. Solution: Using NGINX Ingress Controller as a guide, added options to increase performance, set the common X-Forwarded-For header, and allow standard media types.
1 parent 14bf60d commit 901b400

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

internal/mode/static/nginx/conf/nginx.conf

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11
load_module /usr/lib/nginx/modules/ngx_http_js_module.so;
22

3-
events {}
3+
worker_processes auto;
44

55
pid /var/run/nginx/nginx.pid;
6-
error_log stderr debug;
6+
error_log stderr info;
7+
8+
events {
9+
worker_connections 1024;
10+
}
711

812
http {
913
include /etc/nginx/conf.d/*.conf;
14+
include /etc/nginx/mime.types;
1015
js_import /usr/lib/nginx/modules/njs/httpmatches.js;
16+
17+
default_type application/octet-stream;
18+
1119
proxy_headers_hash_bucket_size 512;
1220
proxy_headers_hash_max_size 1024;
1321
server_names_hash_bucket_size 256;
1422
server_names_hash_max_size 1024;
1523
variables_hash_bucket_size 512;
1624
variables_hash_max_size 1024;
1725

26+
sendfile on;
27+
tcp_nopush on;
28+
1829
server {
1930
listen unix:/var/run/nginx/nginx-status.sock;
2031
access_log off;

internal/mode/static/nginx/config/servers_template.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ server {
5151
proxy_set_header {{ $h.Name }} "{{ $h.Value }}";
5252
{{- end }}
5353
proxy_set_header Host $gw_api_compliant_host;
54+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
5455
proxy_http_version 1.1;
5556
proxy_set_header Upgrade $http_upgrade;
5657
proxy_set_header Connection $connection_upgrade;

0 commit comments

Comments
 (0)