Skip to content

Commit

Permalink
Optimize default nginx config (#1040)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sjberman authored Sep 7, 2023
1 parent 14bf60d commit 901b400
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/mode/static/nginx/conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
load_module /usr/lib/nginx/modules/ngx_http_js_module.so;

events {}
worker_processes auto;

pid /var/run/nginx/nginx.pid;
error_log stderr debug;
error_log stderr info;

events {
worker_connections 1024;
}

http {
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/mime.types;
js_import /usr/lib/nginx/modules/njs/httpmatches.js;

default_type application/octet-stream;

proxy_headers_hash_bucket_size 512;
proxy_headers_hash_max_size 1024;
server_names_hash_bucket_size 256;
server_names_hash_max_size 1024;
variables_hash_bucket_size 512;
variables_hash_max_size 1024;

sendfile on;
tcp_nopush on;

server {
listen unix:/var/run/nginx/nginx-status.sock;
access_log off;
Expand Down
1 change: 1 addition & 0 deletions internal/mode/static/nginx/config/servers_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ server {
proxy_set_header {{ $h.Name }} "{{ $h.Value }}";
{{- end }}
proxy_set_header Host $gw_api_compliant_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
Expand Down

0 comments on commit 901b400

Please sign in to comment.