Go to file
Léo Colombaro 52e13535b4 Add test vhosts and Travis CI config 2019-02-11 16:18:43 +01:00
.github Create CODEOWNERS 2018-11-25 18:25:04 +01:00
conf.d Move server config to conf.d folder 2019-02-01 21:57:51 +01:00
docs Remove outdated docs and fix repo structure 2019-02-04 14:09:06 +01:00
h5bp Add default recommended headers 2019-02-10 22:20:05 +01:00
test/vhosts Add test vhosts and Travis CI config 2019-02-11 16:18:43 +01:00
.editorconfig Fix external links 2018-11-23 14:45:12 +01:00
.gitattributes Add test vhosts and Travis CI config 2019-02-11 16:18:43 +01:00
.gitignore Add test vhosts and Travis CI config 2019-02-11 16:18:43 +01:00
.travis.yml Add test vhosts and Travis CI config 2019-02-11 16:18:43 +01:00
CHANGELOG.md oops 2017-05-06 19:31:51 +02:00
LICENSE.txt Update repo documentation 2018-11-23 13:32:36 +01:00
README.md Add test vhosts and Travis CI config 2019-02-11 16:18:43 +01:00
mime.types Fix MIME-type 2019-02-10 20:32:53 +01:00
nginx.conf Switch from location directives to maps based on MIME-types 2019-02-10 21:56:10 +01:00

README.md

Nginx Server Configs

Build Status

Nginx Server Configs is a collection of configuration snippets that can help your server improve the web site'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

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 of the server definitions.

    Except if they are dot prefixed or non .conf extension, all files in this folder are loaded automatically.

    • templates folder

      Files in this folder contain a server{} template for secure and non-secure hosts. They are intended to be copied in the conf.d folder with all example.com occurrences changed to the target host.

  • h5bp/

    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.

    • basic.conf

      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.

    • location/

      Files in this folder contain one or more location directives. They are intended to be loaded in the server context (or, in a nested location block).

  • mime.types

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

  • nginx.conf

    The main nginx config file.

Other resources

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.

Directly

To use directly, replace the nginx config directory with this repository. for example:

nginx stop
cd /etc
mv nginx nginx-previous
git clone https://github.com/h5bp/server-configs-nginx.git nginx
# install-specific edits
nginx start

Manage sites

$ cd /etc/nginx/conf.d
  • Creating a new site

    $ cp templates/example.com.conf .actual-hostname.conf
    $ sed -i 's/example.com/actual-hostname/g' .actual-hostname.conf
    
  • Enabling a site

    $ mv .actual-hostname.conf actual-hostname.conf
    
  • Disabling a site

    $ mv actual-hostname.conf .actual-hostname.conf
    
$ nginx reload

Support

  • Nginx v1.8.0+

Contributing

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

Acknowledgements

Nginx Server Configs is only possible thanks to all the awesome contributors!

License

The code is available under the MIT license.