Github url


by h5bp

Nginx HTTP server boilerplate configs

8.6K Stars 1.2K Forks Last release: 3 months ago (3.2.0) MIT License 440 Commits 6 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Nginx Server 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.

Getting Started

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


file contains appropriate values for your specific install.

Most specific variables are:

  • user
  • error\_log
  • pid
  • access\_log

Nginx test and restart

  • To verify Nginx config
nginx -t
  • To verify Nginx config with a custom file
nginx -t -c nginx.conf
  • To reload Nginx and apply the new config
nginx -s reload

Basic structure

This repository has the following structure:

./ ├── conf.d/ │ ├── default.conf │ └── templates/ ├── h5bp/ │ ├── basic.conf │ ├── location/ │ └── .../ ├── mime.types └── nginx.conf
  • *``` conf.d/

This directory should contain all the



Except if they are dot prefixed or non


extension, all files in this folder are loaded automatically.

**``` templates


Files in this folder contain a


 template for secure and non-secure hosts. They are intended to be copied in the 


 folder with all

 occurrences 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


 file includes the rules which are recommended to always be defined.


Files in this folder contain one or more


 directives. They are intended to be loaded in the 


 context (or, in a nested 



The mime.types file is responsible for mapping file extensions to mime types.


The main Nginx config file.

## Usage

### As a reference

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](

### Directly

To use directly, replace the Nginx config directory with this repository. For example:

nginx -s stop cd /etc mv nginx nginx-previous git clone nginx # install-specific edits nginx

### Manage sites

cd /etc/nginx/conf.d

- Creating a new site

cp templates/ .actual-hostname.conf sed -i 's/' .actual-hostname.conf

- Enabling a site

mv .actual-hostname.conf actual-hostname.conf

- Disabling a site

mv actual-hostname.conf .actual-hostname.conf

nginx -s reload



  • Nginx v1.8.0+


Anyone is welcome to contribute, however, if you decide to get involved, please take a moment to review the guidelines:


Nginx Server Configs is only possible thanks to all the awesomecontributors!


The code is available under the MIT license.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.