2010-12-15 06:12:17 +01:00
|
|
|
# Set another default user than root for security reasons
|
2013-01-12 20:33:17 +01:00
|
|
|
user www www;
|
2010-12-15 06:12:17 +01:00
|
|
|
|
|
|
|
# As a thumb rule: One per CPU. If you are serving a large amount
|
|
|
|
# of static files, which requires blocking disk reads, you may want
|
|
|
|
# to increase this from the number of cpu_cores available on your
|
|
|
|
# system.
|
|
|
|
#
|
|
|
|
# The maximum number of connections for Nginx is calculated by:
|
|
|
|
# max_clients = worker_processes * worker_connections
|
|
|
|
worker_processes 1;
|
|
|
|
|
|
|
|
# Maximum file descriptors that can be opened per process
|
|
|
|
# This should be > worker_connections
|
|
|
|
worker_rlimit_nofile 8192;
|
|
|
|
|
|
|
|
events {
|
|
|
|
# When you need > 8000 * cpu_cores connections, you start optimizing
|
|
|
|
# your OS, and this is probably the point at where you hire people
|
|
|
|
# who are smarter than you, this is *a lot* of requests.
|
2013-01-12 21:16:02 +01:00
|
|
|
worker_connections 8000;
|
2010-12-15 06:12:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Change these paths to somewhere that suits you!
|
2013-01-12 20:33:17 +01:00
|
|
|
error_log logs/error.log;
|
|
|
|
pid logs/nginx.pid;
|
2010-12-15 06:12:17 +01:00
|
|
|
|
|
|
|
http {
|
|
|
|
# Set the mime-types via the mime.types external file
|
2013-01-12 20:33:17 +01:00
|
|
|
include mime.types;
|
2010-12-15 06:12:17 +01:00
|
|
|
|
|
|
|
# And the fallback mime-type
|
2013-01-12 20:33:17 +01:00
|
|
|
default_type application/octet-stream;
|
2010-12-15 06:12:17 +01:00
|
|
|
|
|
|
|
# Format for our log files
|
2013-01-12 20:33:17 +01:00
|
|
|
log_format main '$remote_addr - $remote_user [$time_local] $status '
|
2010-12-15 06:12:17 +01:00
|
|
|
'"$request" $body_bytes_sent "$http_referer" '
|
|
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
|
|
|
|
# Click tracking!
|
2013-01-12 20:33:17 +01:00
|
|
|
access_log logs/access.log main;
|
2010-12-15 06:12:17 +01:00
|
|
|
|
2012-09-05 17:38:16 +02:00
|
|
|
# Hide nginx version
|
|
|
|
server_tokens off;
|
|
|
|
|
2010-12-15 06:12:17 +01:00
|
|
|
# ~2 seconds is often enough for HTML/CSS, but connections in
|
|
|
|
# Nginx are cheap, so generally it's safe to increase it
|
2011-07-07 02:11:50 +02:00
|
|
|
keepalive_timeout 20;
|
2010-12-15 06:12:17 +01:00
|
|
|
|
|
|
|
# You usually want to serve static files with Nginx
|
|
|
|
sendfile on;
|
|
|
|
|
|
|
|
tcp_nopush on; # off may be better for Comet/long-poll stuff
|
|
|
|
tcp_nodelay off; # on may be better for Comet/long-poll stuff
|
|
|
|
|
2011-07-07 02:11:50 +02:00
|
|
|
# Enable Gzip:
|
|
|
|
gzip on;
|
2010-12-15 06:12:17 +01:00
|
|
|
gzip_http_version 1.0;
|
2011-07-07 02:11:50 +02:00
|
|
|
gzip_comp_level 5;
|
|
|
|
gzip_min_length 512;
|
2010-12-15 06:12:17 +01:00
|
|
|
gzip_proxied any;
|
2011-02-02 00:21:18 +01:00
|
|
|
gzip_types
|
|
|
|
# text/html is always compressed by HttpGzipModule
|
|
|
|
text/css
|
|
|
|
text/plain
|
|
|
|
text/x-component
|
|
|
|
application/javascript
|
|
|
|
application/json
|
|
|
|
application/xml
|
2012-06-19 07:00:12 +02:00
|
|
|
application/xhtml+xml
|
2012-06-14 13:05:47 +02:00
|
|
|
application/x-font-ttf
|
|
|
|
application/x-font-opentype
|
2011-02-02 00:21:18 +01:00
|
|
|
application/vnd.ms-fontobject
|
2012-06-19 07:00:12 +02:00
|
|
|
image/svg+xml
|
|
|
|
image/x-icon;
|
2010-12-15 06:12:17 +01:00
|
|
|
|
2011-07-07 02:11:50 +02:00
|
|
|
# This should be turned on if you are going to have pre-compressed copies (.gz) of
|
|
|
|
# static files available. If not it should be left off as it will cause extra I/O
|
|
|
|
# for the check. It would be better to enable this in a location {} block for
|
|
|
|
# a specific directory:
|
|
|
|
# gzip_static on;
|
2010-12-15 06:12:17 +01:00
|
|
|
|
2013-01-12 20:33:17 +01:00
|
|
|
gzip_disable "msie6";
|
|
|
|
gzip_vary on;
|
2010-12-15 06:12:17 +01:00
|
|
|
|
2012-07-23 12:45:05 +02:00
|
|
|
include sites-enabled/*;
|
2010-12-15 06:12:17 +01:00
|
|
|
}
|