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
This commit is contained in:
parent
8e4c2d5125
commit
6ca197bb2f
50
nginx.conf
50
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
|
||||
# <script src="application.js?20110529">
|
||||
#
|
||||
# Just be careful if your using this on a frequently
|
||||
# updated static site. You may want to crank this back
|
||||
# to 5m which is 5 minutes.
|
||||
expires 1M; # yes one month
|
||||
|
||||
# Static assets
|
||||
location ~* ^.+\.(manifest|appcache)$ {
|
||||
expires -1;
|
||||
root /sites/example.com/public;
|
||||
access_log logs/static.log;
|
||||
}
|
||||
|
||||
# Set expires max on static file types
|
||||
# Set expires max on static file types (make sure you are using cache busting filenames or query params):
|
||||
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
|
||||
expires max;
|
||||
root /sites/example.com/public;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue