• Stars
    star
    11,104
  • Rank 3,028 (Top 0.06 %)
  • Language
  • License
    MIT License
  • Created over 11 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Nginx HTTP server boilerplate configs

Nginx Server Configs

Test

Nginx Server Configs is a collection of configuration files 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.

Check nginx.conf settings

The first thing to check is that the nginx.conf 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

Repository structure

This repository has the following structure:

./
β”œβ”€β”€ conf.d/
β”‚   β”œβ”€β”€ default.conf
β”‚   └── templates/
β”œβ”€β”€ h5bp/
β”‚   β”œβ”€β”€ basic.conf
β”‚   β”œβ”€β”€ location/
β”‚   └── .../
β”œβ”€β”€ custom.d/
β”‚   └── .../
β”œβ”€β”€ mime.types
└── nginx.conf
  • conf.d/

    This directory should contain all the server definitions.

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

    • templates folder

      Files in this directory contain a server template for secure and non-secure hosts. They are intended to be copied in the conf.d directory 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. The basic.conf file includes the rules which are recommended to always be defined.

    • location/

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

  • custom.d/

    This directory should contain all the custom nginx.conf configuration.

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

  • mime.types

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

  • nginx.conf

    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 https://github.com/h5bp/server-configs-nginx.git nginx
# install-specific edits
nginx

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 -s 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.

More Repositories

1

Front-end-Developer-Interview-Questions

A list of helpful front-end related questions you can use to interview potential candidates, test yourself or completely ignore.
Nunjucks
59,382
star
2

html5-boilerplate

A professional front-end template for building fast, robust, and adaptable web apps or sites.
JavaScript
56,323
star
3

Effeckt.css

This repo is archived. Thanks!
CSS
10,883
star
4

mobile-boilerplate

DEPRECATED - A front-end template that helps you build fast, modern mobile web apps.
ApacheConf
3,861
star
5

server-configs-apache

Apache HTTP server boilerplate configs
Shell
3,193
star
6

server-configs

Boilerplate configurations for various web servers.
3,097
star
7

lazyweb-requests

Get projects and ideas built by the community
1,688
star
8

ant-build-script

Ant build script intended for use with HTML5 Boilerplate. You may find something useful here, but this project is archived.
Shell
985
star
9

html5please

Graded Feature Support: Look up web technologies and find out if they are ready for use.
JavaScript
837
star
10

html5boilerplate.com

Files for the HTML5 Boilerplate website.
HTML
487
star
11

mothereffinganimatedgif

Make your animated gifs in the browser! Oh yeah!
JavaScript
378
star
12

server-configs-node

Express / Connect middleware for websites. Goes well with HTML5 Boilerplate.
JavaScript
342
star
13

server-configs-iis

IIS Web.Config Boilerplates
338
star
14

movethewebforward

Project archived.
JavaScript
284
star
15

create-html5-boilerplate

npx quick start for html5-boilerplate
JavaScript
283
star
16

generator-h5bp

Archived!
JavaScript
239
star
17

main.css

A repository for the development of the HTML5 Boilerplate CSS file, main.css
CSS
201
star
18

generator-server-configs

This project is archived
JavaScript
136
star
19

html5-boilerplate-template

HTML5-Boilerplate Template Repo
CSS
115
star
20

h5bp.github.io

A website for the H5BP organization. Browse all the H5BP projects in one place.
JavaScript
84
star
21

generator-mobile-boilerplate

Scaffolds out H5BP Mobile Boilerplate
JavaScript
76
star
22

server-configs-gae

Google App Engine (GAE) app boilerplate config
62
star
23

server-configs-lighttpd

Lighttpd HTTP server boilerplate configs
55
star
24

html5boilerplate.com-mobile

Deprecated- thanks!
JavaScript
40
star
25

server-configs-test

Tests for HTTP server boilerplate configs
JavaScript
40
star
26

.github

The readme for the @h5bp organization's homepage
4
star