Nginx1.x personnal configuration and website templates on Debian linux distribution.
Note: I use those templates for my own projects, they contain the features I need.
Requirements | Configuration | Templates | Documentation | Contributing | License
- Debian linux distribution: ~10.0
- nginx: ~1.18
- openssl: ~1.1.1i
I do not modify any NGINX configuration files. I just add new configuration files to override the default NGINX configuration.
According to the nginx.conf file, when it starts, NGINX includes the module configuration files (/etc/nginx/modules-enabled/*.conf) and, then, the particular configuration snippets (/etc/nginx/conf.d/*.conf) which manage global configuration fragments.
- brotli.conf: configures brotli compression.
- cache.conf: configures the cache.
- dir.conf: defines files that will be used as an index.
- expires.conf: configures the expires, the cache_control and the etag directives. Defines map filters using content_type. MANDATORY.
- fastcgi.conf: configures common fastcgi settings.
- gzip.conf: configures gzip compression.
- headers.conf: adds few HTTP request and response headers customizations. MANDATORY.
- http2: configures http2.
- limits.conf: configures request processing rate.
- log.conf: defines log formats. MANDATORY.
- mime.conf: adds more mime types.
- nginx.conf: overrides the main nginx configuration.
- realip.conf: configures settings to get real_ip IP address in log files.
- ssl.conf: SSL configuration. MANDATORY.
- Copy the configuration files into /etc/nginx/conf-available
- Edit the named like *.conf files and make changes as you need.
- Enable the configuration:
- using
./nginxenconf.sh <filename without extention>
. Ex:./nginxenconf.sh headers
- or using
ln -s /etc/nginx/conf-available/headers.conf /etc/nginx/conf.d/headers.conf
- Test the configuration using
nginx -t
- When test is OK, activate the new configuration using
nginx -s reload
orsystemctl restart nginx.service
I wrote these templates to ease the process of creating server blocks.
Each domain.tld directory contains configuration for HTTP and HTTPS. The domain.tld/include contains the common snippets for HTTP and HTTPS.
The Content Security Policy (CSP) snippets depends on your site and must be tested.
- 000-default: contains the default Server Blocks configuration.
- static.tld: template for a static website.
- app.tld: template for a PHP application.
- api.tld: template for a mixed static website and PHP application.
- redirect.tld: template for a redirection.
- reverseproxy.tld: template for a reverse proxy.
- loader.conf: one file to rule them all.
- snippets: contains many files with common snippets.
- access_control directory contains access control directives for application and static website.
- headers directory contains CORS directives.
- security directory contains security directives for access restriction, HSTS directives and WordPress security rules.
- Copy the templates into /etc/nginx/sites-available
- Edit the files and make changes as you need.
- Edit and update the loader.conf file.
- Enable the sites using
ln -s /etc/nginx/sites-available/loader.conf /etc/nginx/sites-enabled/loader
- Test the configuration using
nginx -t
- restarts the nginx daemon using
nginx -s reload
orsystemctl restart nginx.service
I wrote and I use this package for my own projects. And, unfortunately, I do not provide exhaustive documentation. Please read the code and the comments ;)
For instructions on how to use, best practices, templates and other usage information, please visit the NGINX documentation.
Thanks you for taking the time to contribute. Please fork the repository and make changes as you'd like.
As I use these configuration and templates for my own projects, it contains only the features I need. But If you have any ideas, just open an issue and tell me what you think. Pull requests are also warmly welcome.
If you encounter any bugs in the configuration or templates, please open an issue.
Be sure to include a title and clear description,as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.
Nginx1.x configuration and templates are open-source and are licensed under the BSD 2-Clause License.