Last active
December 14, 2015 12:08
-
-
Save jalaziz/5083919 to your computer and use it in GitHub Desktop.
html5bp nginx config for Ubuntu
This file contains 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
# Set another default user than root for security reasons | |
user www-data; | |
# 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 4; | |
# PID file | |
pid /var/run/nginx.pid; | |
# 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. | |
worker_connections 8000; | |
# multi_accept on; | |
} | |
http { | |
# Set the mime-types via the mime.types external file | |
include mime.types; | |
# And the fallback mime-type | |
default_type application/octet-stream; | |
# Format for our log files | |
log_format main '$remote_addr - $remote_user [$time_local] $status ' | |
'"$request" $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
# Logging | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
# Hide nginx version | |
server_tokens off; | |
# ~2 seconds is often enough for HTML/CSS, but connections in | |
# Nginx are cheap, so generally it's safe to increase it | |
keepalive_timeout 20; | |
# 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 | |
# Enable Gzip: | |
gzip on; | |
gzip_http_version 1.0; | |
gzip_comp_level 5; | |
gzip_min_length 512; | |
gzip_buffers 4 8k; | |
gzip_proxied any; | |
gzip_types | |
# text/html is always compressed by HttpGzipModule | |
text/css | |
text/plain | |
text/x-component | |
application/javascript | |
application/json | |
application/xml | |
application/xhtml+xml | |
application/x-font-ttf | |
application/x-font-opentype | |
application/vnd.ms-fontobject | |
image/svg+xml | |
image/x-icon; | |
# 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; | |
gzip_disable "msie6"; | |
gzip_vary on; | |
include /etc/nginx/conf.d/*.conf; | |
include /etc/nginx/sites-enabled/*; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment