From 6ca197bb2fae01ce805485f8c3bc6c3c746bc303 Mon Sep 17 00:00:00 2001 From: sean Date: Wed, 6 Jul 2011 17:11:50 -0700 Subject: [PATCH] nginx.conf Improvements/Corrections Don't think it makes sense to turn this off for a single worker and it's on by default. The docs indicate that Nginx will use the best method based on the available methods Keepalive of 5 seems very low - i've seen recommendations of 10-20 gzip_proxied was set twice gzip_static should be off unless actually used default is deprecated server_name _; shouldn't be used Shoudn't use expires in the server {} block - should be inside location {} Extra root lines not needed gzip_comp_level seems too low gzip_min_length seems too high --- nginx.conf | 50 ++++++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/nginx.conf b/nginx.conf index 66e1651..d94a337 100644 --- a/nginx.conf +++ b/nginx.conf @@ -19,16 +19,6 @@ events { # 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; - - # This sets up some smart queueing for accept(2)'ing requests - # Set it to "on" if you have > worker_processes - accept_mutex off; - - # These settings are OS specific, by defualt Nginx uses select(2), - # however, for a large number of requests epoll(2) and kqueue(2) - # are generally faster than the default (select(2)) - # use epoll; # enable for Linux 2.6+ - # use kqueue; # enable for *BSD (FreeBSD, OS X, ..) } # Change these paths to somewhere that suits you! @@ -52,7 +42,7 @@ http { # ~2 seconds is often enough for HTML/CSS, but connections in # Nginx are cheap, so generally it's safe to increase it - keepalive_timeout 5; + keepalive_timeout 20; # You usually want to serve static files with Nginx sendfile on; @@ -60,12 +50,12 @@ http { 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; + # Enable Gzip: + gzip on; gzip_http_version 1.0; - gzip_comp_level 2; - gzip_min_length 1100; - gzip_buffers 4 8k; + gzip_comp_level 5; + gzip_min_length 512; + gzip_buffers 4 8k; gzip_proxied any; gzip_types # text/html is always compressed by HttpGzipModule @@ -83,20 +73,23 @@ http { application/vnd.ms-fontobject image/svg+xml; - gzip_static on; + # 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_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; gzip_vary on; server { - # listen 80 default deferred; # for Linux - # listen 80 default accept_filter=httpready; # for FreeBSD - listen 80 default; + # listen 80 default_server deferred; # for Linux + # listen 80 default_server accept_filter=httpready; # for FreeBSD + listen 80 default_server; # e.g. "localhost" to accept all connections, or "www.example.com" # to handle the requests for "example.com" (and www.example.com) - server_name _; + # server_name www.example.com; # Path for static files root /sites/example.com/public; @@ -104,26 +97,15 @@ http { # Custom 404 page error_page 404 /404.html; - # This is pretty long expiry and assume your using - # cachebusting with query params like - #