diff options
-rw-r--r-- | examples/nginx.conf | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/examples/nginx.conf b/examples/nginx.conf index 70d1851..52ec245 100644 --- a/examples/nginx.conf +++ b/examples/nginx.conf @@ -98,7 +98,16 @@ http { # path for static files root /path/to/app/current/public; - location / { + # Prefer to serve static files directly from nginx to avoid unnecessary + # data copies from the application server. + # + # try_files directive appeared in in nginx 0.7.27 and has stabilized + # over time. Older versions of nginx (e.g. 0.6.x) requires + # "if (!-f $request_filename)" which was less efficient: + # http://bogomips.org/unicorn.git/tree/examples/nginx.conf?id=v3.3.1#n127 + try_files $uri/index.html $uri.html $uri @app; + + location @app { # an HTTP header important enough to have its own Wikipedia entry: # http://en.wikipedia.org/wiki/X-Forwarded-For proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -122,12 +131,7 @@ http { # clients, really. # proxy_buffering off; - # Try to serve static files from nginx, no point in making an - # *application* server like Unicorn/Rainbows! serve static files. - if (!-f $request_filename) { - proxy_pass http://app_server; - break; - } + proxy_pass http://app_server; } # Rails error pages |