Generally, using "if" is a bad practice (according to author of nginx). if possible, better to use try_file of error_page directives instead "if (-f ...)"
Combining tip with maintenence.html file and tip with try_files we get:
We set up Nginx with Chef, using this cookbook which contains scripts for handling nginx configuration similar to how Debian does Apache2, and also some sample templates with sane defaults.
I also posted a while ago about how to properly handle gzip compression with nginx as older browsers may have issues with just a blanket gzip statement. HTH.
How to combine HTTP and HTTPS blocks.
This was posted as an answer to a different question. See here.
By far, the best tips I have ever seen are from the author on it's pitfall page: https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
Generally, using "if" is a bad practice (according to author of nginx). if possible, better to use try_file of error_page directives instead "if (-f ...)"
Combining tip with maintenence.html file and tip with try_files we get:
When maintenance ends, just mv maintenance.html from $root.
Configure nginx to use stronger SSL ciphers. By default, SSLv2 is enabled (which you should disable if possible).
http://tumblelog.jauderho.com/post/121851623/nginx-and-stronger-ssl
Its often more efficient to use the
map
directive in place of regular expressions when switching the root for matching subdomains:The
empty_gif
module is also very useful, especially if you need monitor responses from the webserver (using nagios/monit/etc):We set up Nginx with Chef, using this cookbook which contains scripts for handling nginx configuration similar to how Debian does Apache2, and also some sample templates with sane defaults.
Here's a good method for returning a maintenance page. All requests are rewritten and the correct http code is returned. (503 - Service unavailable)
From nginx 0.7.12 and later, a "" is usable in server_name to catch requests without a "Host" header.
You can use the following as a catchall for undefined virtual hosts.
I also posted a while ago about how to properly handle gzip compression with nginx as older browsers may have issues with just a blanket gzip statement. HTH.
http://tumblelog.jauderho.com/post/27655495/gzip-compression-with-nginx