explaingit

h5bp/server-configs-nginx

11,560Audience · ops devopsComplexity · 2/5LicenseSetup · moderate

TLDR

A collection of ready-to-use Nginx configuration snippets covering security, caching, CORS, and file handling. Use them as a reference or drop them in as a base config for your web server.

Mindmap

mindmap
  root((repo))
    What It Does
      Security hardening
      Caching headers
      MIME type mapping
      Font CORS support
    Structure
      Main config file
      Site definitions
      Reusable snippets
      Custom configs dir
    How To Use
      Copy snippets
      Replace base config
    Audience
      Web developers
      DevOps engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Copy security and caching headers into an existing Nginx setup without researching each setting from scratch

USE CASE 2

Use the repository as a starter config when setting up a new web server for a website or web app

USE CASE 3

Enable cross-origin font loading on your Nginx-served site by pulling in the relevant CORS snippet

Tech stack

Nginx

Getting it running

Difficulty · moderate Time to first run · 30min

Requires Nginx 1.8.0 or later, template site files must be manually edited to point at your domain names.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

This repository is a collection of Nginx configuration files assembled by the HTML5 Boilerplate project. Nginx is a widely used web server, and configuring it well involves a lot of small decisions about performance, security, caching, and file handling. This project packages up those decisions into ready-to-use config snippets so developers do not have to figure them out from scratch. The configs cover things like setting correct content types for different file formats, adding cache expiry headers, allowing fonts to load across domains, protecting system files from being served publicly, and other settings that improve how a website performs and behaves for visitors. The repository is organized around a main Nginx config file, a directory of server definitions (one per site), a directory of reusable config snippets, a custom configs directory, and a mime.types file that maps file extensions to their correct content types. The h5bp directory contains the core snippets, including a basic.conf file that loads a recommended minimum set of rules and a location directory with additional per-route directives. You can use this project in two ways. As a reference, you browse the files and copy the relevant parts into your existing Nginx setup. As a direct replacement, you clone the repository into your server's Nginx config directory and adjust the template files to point at your actual domain names. Site files are enabled or disabled by adding or removing a dot prefix from the filename, which controls whether Nginx loads them automatically. The project requires Nginx version 1.8.0 or later and is available under the MIT license.

Copy-paste prompts

Prompt 1
I'm setting up Nginx for a new web app using the h5bp server-configs-nginx repo as my base. Walk me through enabling HTTPS with redirect from HTTP, applying the security headers from h5bp, and setting cache expiry for static assets.
Prompt 2
Using the h5bp nginx configs, help me configure a new site file that proxies API requests to a Node.js app on port 3000 while serving static files directly.
Prompt 3
I want to use server-configs-nginx as a reference. Which snippets should I copy to get good security headers, correct MIME types, and cache control for a static HTML site?
Prompt 4
Help me adapt the h5bp nginx site template to serve a Python Flask app with gunicorn on a Unix socket, using their recommended performance and security settings.
Open on GitHub → Explain another repo

← h5bp on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.