Nginx HTTP server boilerplate configs
Nginx Server Configs is a collection of configuration snippets that can help your server improve the website's performance and security, while also ensuring that resources are served with the correct content-type and are accessible, if needed, even cross-domain.
Using the Nginx server configs repo directly has a few required steps to be able to work.
The first thing to check is that the
nginx.conffile contains appropriate values for your specific install.
Most specific variables are:
nginx -t -c nginx.conf
nginx -s reload
This repository has the following structure:
./ ├── conf.d/ │ ├── default.conf │ └── templates/ ├── h5bp/ │ ├── basic.conf │ ├── location/ │ └── .../ ├── mime.types └── nginx.conf
This directory should contain all the
Except if they are dot prefixed or non
.confextension, all files in this folder are loaded automatically.
Files in this folder contain a
servertemplate for secure and non-secure hosts. They are intended to be copied in the
conf.dfolder with all
example.comoccurrences changed to the target host.
This directory contains config snippets (mixins) to be included as desired.
There are two types of config files provided, individual config snippets and combined config files which provide convenient defaults.
This file loads a small subset of the rules provided by this repository to add expires headers, allow cross-domain fonts and protect system files from web access. The
basic.conffile includes the rules which are recommended to always be defined.
Files in this folder contain one or more
locationdirectives. They are intended to be loaded in the
servercontext (or, in a nested
The mime.types file is responsible for mapping file extensions to mime types.
The main Nginx config file.
To use as reference requires no special installation steps, download/checkout the repository to a convenient location and adapt your existing Nginx configuration incorporating the desired functionality from this repository.
Download the latest release archive.
To use directly, replace the Nginx config directory with this repository. For example:
nginx -s stop cd /etc mv nginx nginx-previous git clone https://github.com/h5bp/server-configs-nginx.git nginx # install-specific edits nginx
cp templates/example.com.conf .actual-hostname.conf sed -i 's/example.com/actual-hostname/g' .actual-hostname.conf
mv .actual-hostname.conf actual-hostname.conf
mv actual-hostname.conf .actual-hostname.conf
nginx -s reload
The code is available under the MIT license.