I want to share my work on setting up nginx, which may help someone at the start of a new project or eliminate the need to copy the next vhost.
I noted two problems of the overwhelming number of nginx configs that caught my eye:
- "All in one file"
- Duplication of settings
With the help of my approach, I hope these and many other problems will be eliminated.
Before collecting all the developments in a separate project, I was looking for something similar, but nothing worthwhile was found.
The project was called
"Nginx boilerplate" . And, by analogy with
HTML5 Boilerplate , it serves as a quick start when setting up a new virtual host.
')
In essence, this is a set of configs that provides:
- Logical branched nginx configuration file structure
- Optimization of default settings
- Templates for limiting the frequency of requests and the number of connections
- Web server-level backend response caching
- A number of predefined locations for various tasks and requirements.
- Improved logging
For example, the default server looks like this at the moment:
server { listen 80 default_server; server_name ""; root /var/www/nginx-bp/test/www/; include nginx-bp/cache.conf; include nginx-bp/limits/methods.conf; include nginx-bp/locations/php.conf; include nginx-bp/locations/favicon.conf; include nginx-bp/locations/static.conf; include nginx-bp/locations/system.conf; location / { include nginx-bp/logs/bots.conf; } }
If you have some cool recipes for nginx - join us!
References: