-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathnginx.conf
136 lines (112 loc) · 4.48 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# User & group that will be used by worker processes.
# For security use a user & group with limited privileges.
user www-data www-data;
# The file that will store a processes id of the main process.
pid /run/nginx.pid;
# Number of worker processes. The optimial value depends on many things:
# number of CPU cores, number of storage drives, etc. Setting it to a total
# number of CPU cores is good starting point, or just leave it to `auto`.
# Max number of connections = worker_processes * worker_connections
worker_processes auto;
# Max number of open files (RLIMIT_NOFILE) for worker processes.
# Should be > worker_connections.
worker_rlimit_nofile 8192;
# Default loging location and level.
error_log /etc/nginx/logs/error.log error;
events {
# Max number of simultaneous connections that can be opened by the worker
# processes. The simultaneous connections cannot exceed the maximum
# number of open files, thus: worker_connections < worker_rlimit_nofile.
worker_connections 8000;
}
http {
# Enable or disable emitting nginx version on response's header.
server_tokens off;
# Max size & bucket size for the server names hash table.
server_names_hash_max_size 1024;
server_names_hash_bucket_size 32;
# Max size & bucket size for the mime types hash table.
types_hash_max_size 2048;
types_hash_bucket_size 32;
# Speed up static file transfers by using the sendfile() rather than the
# read() and write() combination. sendfile() has the ability to transfer
# data from the file descriptor.
sendfile on;
# Optimize the amount of data that is being sent at once. Prevent Nginx
# from sending a partial frame. As a result it will increases the
# throughput, since TCP frames will be filled up before being sent out.
# You also need to activate the `sendfile` option.
tcp_nopush on;
# By default, the TCP stack implements a mechanism to delay sending the
# data up to 200ms. To force a socket to send the data in its buffer
# immediately we can turn this option on.
tcp_nodelay on;
# A timeout of which a keep-alive connection will stay open. Longer
# duration are better for client, especially on SSL, the downside is the
# worker connection is occupied longer.
keepalive_timeout 20s;
# Mime types.
include mime.types;
default_type application/octet-stream;
# Update the charset to match the updated mime.types.
# By efault the `text/html` is always included by the charset module.
charset_types
text/css
text/plain
text/vnd.wap.wml
application/javascript
application/json
application/rss+xml
application/xml;
# Request log format.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# The request log file path.
access_log /etc/nginx/logs/access.log main;
# Enable gzip compression.
gzip on;
# Gzip compression level (1-9).
# 5 is a perfect compromise between size and CPU usage, offering about
# 75% reduction for most ASCII files (almost identical to level 9).
gzip_comp_level 5;
# Don't compress a small file that is unlikely to shrink much. The small
# file is also usually ended up in larger file sizes after gzipping.
gzip_min_length 256;
# Compress data even for a proxied connection.
gzip_proxied any;
# Cache both the regular and the gzipped versions of a resource whenever
# client's Accept-Encoding capabilities header varies.
gzip_vary on;
# Compress all of the following mime-types, `text/html` is always
# compressed.
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
# Include other custom configurations.
include conf.d/*.conf;
# Include site configurations.
include sites-enabled/*;
}