What best practices do you use while using NGinx?
feedback
|
|
How to combine HTTP and HTTPS blocks.
This was posted as an answer to a different question. See here. | |||
|
feedback
|
|
By far, the best tips I have ever seen are from the author on it's pitfall page: http://wiki.nginx.org/Pitfalls | ||||
|
feedback
|
|
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:
location / {
try_files /maintenance.html $uri $uri/ @wordpress;
}
When maintenance ends, just mv maintenance.html from $root. | |||||
feedback
|
|
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 | ||||
|
feedback
|
|
The
| |||||||||||||
feedback
|
|
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. | |||
|
feedback
|
|
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.
| |||||||||||
feedback
|
|
Its often more efficient to use the
| |||||
feedback
|
|
I don't know if it is a best practice, but definitely a neat hack to get nested conditions in nginx. Here's a sample from the nginx wiki.
| |||||
feedback
|
|
Here's a good method for returning a maintenance page. All requests are rewritten and the correct http code is returned. (503 - Service unavailable)
| |||||||
feedback
|
|
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 | |||
|
feedback
|
|
If you need to flip contextually between http and https for subdomains handled by the same server block, you can use variables to do so. Might not be the most efficient way to do things, but it works:
| |||
|
feedback
|
|
I always try to use the The Pitfalls Page from the Nginx wiki has some great tips about best practices. | ||||
|
feedback
|
|
Did you take a look over here? | |||
|
feedback
|
|
If you are using nginx as a proxy, having the timeout settings adjusted can be important to ensure you are not having nginx drop connections before your application is done with them, especially if you are dealing with a high traffic application:
| ||||
|
feedback
|