diff --git a/nginx/mime.types b/nginx/mime.types index 3f486a2..af3a33c 100644 --- a/nginx/mime.types +++ b/nginx/mime.types @@ -1,31 +1,64 @@ types { - text/html html htm shtml; - text/css css; - text/cache-manifest manifest appcache; - text/mathml mml; - text/plain txt; - text/vnd.sun.j2me.app-descriptor jad; - text/vnd.wap.wml wml; - text/x-component htc; - text/x-vcard vcf; - # JavaScript - application/javascript js jsonp; - application/json json; +# Audio + audio/midi mid midi kar; + audio/mp4 aac f4a f4b m4a; + audio/mpeg mp3; + audio/ogg oga ogg; + audio/x-realaudio ra; + audio/x-wav wav; - # Images +# Images + image/bmp bmp; + image/gif gif; + image/jpeg jpeg jpg; image/png png; - image/svg+xml svg svgz; image/tiff tif tiff; image/vnd.wap.wbmp wbmp; image/webp webp; image/x-icon ico; image/x-jng jng; - image/bmp bmp; - image/gif gif; - image/jpeg jpeg jpg; - application/xml rss atom xml rdf; +# JavaScript + application/javascript js jsonp; + application/json json; + +# Manifest files + application/x-web-app-manifest+json webapp; + text/cache-manifest manifest appcache; + +# Microsoft Office + application/msword doc; + application/vnd.ms-excel xls; + application/vnd.ms-powerpoint ppt; + application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; + application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; + +# Video + video/3gpp 3gpp 3gp; + video/mp4 mp4 m4v f4v f4p; + video/mpeg mpeg mpg; + video/ogg ogv; + video/quicktime mov; + video/webm webm; + video/x-flv flv; + video/x-mng mng; + video/x-ms-asf asx asf; + video/x-ms-wmv wmv; + video/x-msvideo avi; + +# Web feeds + application/xml atom rdf rss xml; + +# Web fonts + application/font-woff woff; + application/vnd.ms-fontobject eot; + application/x-font-ttf ttc ttf; + font/opentype otf; + image/svg+xml svg svgz; + +# Other application/java-archive jar war ear; application/mac-binhex40 hqx; application/pdf pdf; @@ -61,38 +94,14 @@ types { application/octet-stream msi msp msm; application/octet-stream safariextz; - # Audio - audio/midi mid midi kar; - audio/mpeg mp3; - audio/ogg oga ogg; - audio/mp4 m4a f4a f4b aac; - audio/x-realaudio ra; - audio/x-wav wav; + text/css css; + text/html html htm shtml; + text/mathml mml; + text/plain txt; + text/vnd.sun.j2me.app-descriptor jad; + text/vnd.wap.wml wml; + text/vtt vtt; + text/x-component htc; + text/x-vcard vcf; - # Video - video/3gpp 3gpp 3gp; - video/mp4 mp4 m4v f4v f4p; - video/mpeg mpeg mpg; - video/ogg ogv; - video/quicktime mov; - video/webm webm; - video/x-flv flv; - video/x-mng mng; - video/x-ms-asf asx asf; - video/x-ms-wmv wmv; - video/x-msvideo avi; - - # Webfonts - application/font-woff woff; - application/vnd.ms-fontobject eot; - application/x-font-ttf ttf ttc; - application/x-font-opentype otf; - - # Microsoft Office - application/msword doc; - application/vnd.ms-excel xls; - application/vnd.ms-powerpoint ppt; - application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; - application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; } diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 5c6e58c..f881b3e 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -1,11 +1,14 @@ +# nginx Configuration File +# http://wiki.nginx.org/Configuration + # Run as a less privileged user for security reasons. user www www; -# How many worker threads to run; "auto" sets it to the number -# of CPU cores available in the system, and offers the best -# performance. Don't set it higher than the number of CPU cores -# if changing this parameter. -# +# How many worker threads to run; +# "auto" sets it to the number of CPU cores available in the system, and +# offers the best performance. Don't set it higher than the number of CPU +# cores if changing this parameter. + # The maximum number of connections for Nginx is calculated by: # max_clients = worker_processes * worker_connections worker_processes auto; @@ -15,21 +18,23 @@ worker_processes auto; 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, as this is *a lot* of requests. + # 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, as this is *a lot* of requests. worker_connections 8000; } -# Default error log file (this is only used when you don't override error_log on a server{} level) +# Default error log file +# (this is only used when you don't override error_log on a server{} level) error_log logs/error.log warn; pid /var/run/nginx.pid; http { + # Hide nginx version information. server_tokens off; - # Define the mime types for files. + # Define the MIME types for files. include /etc/nginx/mime.types; default_type application/octet-stream; @@ -38,7 +43,8 @@ http { '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; - # Default log file (this is only used when you don't override access_log on a server{} level) + # Default log file + # (this is only used when you don't override access_log on a server{} level) access_log logs/access.log main; # How long to allow each connection to stay idle; longer values are better @@ -59,30 +65,55 @@ http { # bandwidth at the cost of a nearly imperceptible increase to latency. (removes TCP_NODELAY) tcp_nodelay off; - # Enable Gzip compressed responses from the server to massively speed up - # resource transfer times, especially for clients on slow connections. - # All browsers since ~1998 support Gzip compression. + + # Compression + + # Enable Gzip compressed. gzip on; - gzip_http_version 1.0; # enable compression both for HTTP/1.0 and HTTP/1.1, required for CloudFront - gzip_disable "msie6"; # disable gzipping for ie 5.5 and ie 6 - gzip_comp_level 5; # level is from 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_min_length 256; # don't compress anything that's already tiny and unlikely to shrink much if at all (the default is 20 bytes, which is bad as that usually leads to larger files after gzipping) - gzip_proxied any; # compress data even for clients that are connecting to us via proxies (identified by the "Via" header), required for CloudFront - gzip_vary on; # tells proxies to cache both the gzipped and regular version of a resource whenever the client's Accept-Encoding capabilities header varies; avoids the issue where a non-gzip capable client (which is extremely rare today) would display gibberish if their proxy gave them the gzipped version + + # Enable compression both for HTTP/1.0 and HTTP/1.1 (required for CloudFront). + gzip_http_version 1.0; + + # 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 anything that's already small and unlikely to shrink much + # if at all (the default is 20 bytes, which is bad as that usually leads to + # larger files after gzipping). + gzip_min_length 256; + + # Compress data even for clients that are connecting to us via proxies, + # identified by the "Via" header (required for CloudFront). + gzip_proxied any; + + # Tell proxies to cache both the gzipped and regular version of a resource + # whenever the client's Accept-Encoding capabilities header varies; + # Avoids the issue where a non-gzip capable client (which is extremely rare + # today) would display gibberish if their proxy gave them the gzipped version. + gzip_vary on; + + # Compress all output labeled with one of the following MIME-types. gzip_types - # text/html is always compressed by HttpGzipModule - text/css - text/plain - text/x-component + application/atom+xml application/javascript application/json - application/xml - application/xhtml+xml - application/x-font-ttf - application/x-font-opentype + application/rss+xml application/vnd.ms-fontobject + application/x-font-ttf + application/x-web-app-manifest+json + application/xhtml+xml + application/xml + font/opentype image/svg+xml - image/x-icon; + image/x-icon + text/css + text/html + text/plain + text/x-component; + # text/html is always compressed by HttpGzipModule + # 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