Created
July 16, 2025 01:50
-
-
Save hungthai1401/5539932d5db83d8e56c80023b0de0feb to your computer and use it in GitHub Desktop.
Improve Nginx config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_processes auto; | |
worker_cpu_affinity auto; | |
# Change the default thread pool settings | |
thread_pool default threads=2 max_queue=16384; | |
error_log /var/log/nginx/error.log notice; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 16384; | |
# Serve many clients each thread (Linux only) | |
use epoll; | |
# Accept as many connections as possible | |
multi_accept on; | |
} | |
http { | |
# Copies data between one FD and other from within the kernel | |
# faster than read() + write() | |
sendfile on; | |
# Use the default thread pool for asynchronous file I/O | |
aio threads; | |
# Only use AIO is used for when larger than or equal to this size | |
directio 6m; | |
# Send headers in one piece, it is better than sending them one by one | |
tcp_nopush on; | |
# Don't buffer data sent, good for small data bursts in real time | |
tcp_nodelay on; | |
# Disable logging if a file can't be found | |
log_not_found off; | |
# Server will close connection after this time | |
keepalive_timeout 65; | |
# Max size of types hash tables (processing static sets of data. eg. server names, map directives or mime types) | |
types_hash_max_size 2048; | |
# Max allowed size of the client request body | |
client_max_body_size 250M; | |
# If the request body size is more than the buffer size, then the entire (or partial) | |
# request body is written into a temporary file | |
client_body_buffer_size 512k; | |
# Request timed out | |
client_body_timeout 300s; | |
# Allow the server to close connection on non responding client, this will free up memory | |
reset_timedout_connection on; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
access_log /var/log/nginx/access.log main; | |
sendfile on; | |
keepalive_timeout 60; | |
gzip on; | |
gzip_disable msie6; | |
gzip_vary on; | |
gzip_comp_level 3; | |
gzip_min_length 256; | |
gzip_buffers 16 8k; | |
gzip_proxied any; | |
gzip_types | |
text/css | |
text/plain | |
text/javascript | |
text/cache-manifest | |
text/vcard | |
text/vnd.rim.location.xloc | |
text/vtt | |
text/x-component | |
text/x-cross-domain-policy | |
application/javascript | |
application/json | |
application/x-javascript | |
application/ld+json | |
application/xml | |
application/xml+rss | |
application/xhtml+xml | |
application/x-font-ttf | |
application/x-font-opentype | |
application/vnd.ms-fontobject | |
application/manifest+json | |
application/rss+xml | |
application/atom_xml | |
application/vnd.geo+json | |
application/x-web-app-manifest+json | |
image/svg+xml | |
image/x-icon | |
image/bmp | |
font/opentype; | |
include /etc/nginx/conf.d/*.conf; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment