|
| 1 | +# you must set worker processes based on your CPU cores, nginx does not benefit from setting more than that |
| 2 | +worker_processes auto; #some last versions calculate it automatically |
| 3 | + |
| 4 | +# number of file descriptors used for nginx |
| 5 | +# the limit for the maximum FDs on the server is usually set by the OS. |
| 6 | +# if you don't set FD's then OS settings will be used which is by default 2000 |
| 7 | +worker_rlimit_nofile 100000; |
| 8 | + |
| 9 | +# only log critical errors |
| 10 | +error_log /var/log/nginx/error.log crit; |
| 11 | + |
| 12 | +# provides the configuration file context in which the directives that affect connection processing are specified. |
| 13 | +events { |
| 14 | + # determines how much clients will be served per worker |
| 15 | + # max clients = worker_connections * worker_processes |
| 16 | + # max clients is also limited by the number of socket connections available on the system (~64k) |
| 17 | + worker_connections 4000; |
| 18 | + |
| 19 | + # optimized to serve many clients with each thread, essential for linux -- for testing environment |
| 20 | + use epoll; |
| 21 | + |
| 22 | + # accept as many connections as possible, may flood worker connections if set too low -- for testing environment |
| 23 | + multi_accept on; |
| 24 | +} |
| 25 | + |
| 26 | +http { |
| 27 | + # Temporary directories for kubernetes "readonlyfilesystem" |
| 28 | + client_body_temp_path /tmp/nginx-client-body; |
| 29 | + proxy_temp_path /tmp/nginx-proxy; |
| 30 | + fastcgi_temp_path /tmp/nginx-fastcgi; |
| 31 | + uwsgi_temp_path /tmp/nginx-uwsgi; |
| 32 | + scgi_temp_path /tmp/nginx-scgi; |
| 33 | + # cache informations about FDs, frequently accessed files |
| 34 | + # can boost performance, but you need to test those values |
| 35 | + open_file_cache max=200000 inactive=20s; |
| 36 | + open_file_cache_valid 30s; |
| 37 | + open_file_cache_min_uses 2; |
| 38 | + open_file_cache_errors on; |
| 39 | + |
| 40 | + # to boost I/O on HDD we can disable access logs |
| 41 | + access_log off; |
| 42 | + |
| 43 | + # copies data between one FD and other from within the kernel |
| 44 | + # faster than read() + write() |
| 45 | + sendfile on; |
| 46 | + |
| 47 | + # send headers in one piece, it is better than sending them one by one |
| 48 | + tcp_nopush on; |
| 49 | + |
| 50 | + # don't buffer data sent, good for small data bursts in real time |
| 51 | + tcp_nodelay on; |
| 52 | + |
| 53 | + # reduce the data that needs to be sent over network -- for testing environment |
| 54 | + gzip on; |
| 55 | + # gzip_static on; |
| 56 | + gzip_min_length 10240; |
| 57 | + gzip_comp_level 1; |
| 58 | + gzip_vary on; |
| 59 | + gzip_disable msie6; |
| 60 | + gzip_proxied expired no-cache no-store private auth; |
| 61 | + gzip_types |
| 62 | + # text/html is always compressed by HttpGzipModule |
| 63 | + text/css |
| 64 | + text/javascript |
| 65 | + text/xml |
| 66 | + text/plain |
| 67 | + text/x-component |
| 68 | + application/javascript |
| 69 | + application/x-javascript |
| 70 | + application/json |
| 71 | + application/xml |
| 72 | + application/rss+xml |
| 73 | + application/atom+xml |
| 74 | + font/truetype |
| 75 | + font/opentype |
| 76 | + application/vnd.ms-fontobject |
| 77 | + image/svg+xml; |
| 78 | + |
| 79 | + # allow the server to close connection on non responding client, this will free up memory |
| 80 | + reset_timedout_connection on; |
| 81 | + |
| 82 | + # request timed out -- default 60 |
| 83 | + client_body_timeout 10; |
| 84 | + |
| 85 | + # if client stop responding, free up memory -- default 60 |
| 86 | + send_timeout 2; |
| 87 | + |
| 88 | + # server will close connection after this time -- default 75 |
| 89 | + keepalive_timeout 30; |
| 90 | + |
| 91 | + # number of requests client can make over keep-alive -- for testing environment |
| 92 | + keepalive_requests 100000; |
| 93 | + |
| 94 | + include /etc/nginx/mime.types; |
| 95 | + |
| 96 | + server { |
| 97 | + listen 80 default_server; |
| 98 | + root /usr/share/nginx/html; |
| 99 | + index index.html index.htm; |
| 100 | + server_name _; |
| 101 | + location / { |
| 102 | + aio threads; |
| 103 | + try_files $uri /index.html; |
| 104 | + } |
| 105 | + location /env.js { |
| 106 | + aio threads; |
| 107 | + add_header Cache-Control "no-cache"; |
| 108 | + } |
| 109 | + location /static/env.js { |
| 110 | + aio threads; |
| 111 | + add_header Cache-Control "no-cache"; |
| 112 | + } |
| 113 | + } |
| 114 | + |
| 115 | +} |
0 commit comments