• Stars
    star
    173
  • Rank 220,124 (Top 5 %)
  • Language
    Shell
  • Created almost 9 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

Push button, get TLS

Let's Nginx

dockerhub build

Put browser-valid TLS termination in front of any Dockerized HTTP service with one command.

docker run --detach \
  --name lets-nginx \
  --link backend:backend \
  --env [email protected] \
  --env DOMAIN=mydomain.horse \
  --env UPSTREAM=backend:8080 \
  --publish 80:80 \
  --publish 443:443 \
  smashwilson/lets-nginx

Issues certificates from letsencrypt, installs them in nginx, and schedules a cron job to reissue them monthly.

âš¡ To run unattended, this container accepts the letsencrypt terms of service on your behalf. Make sure that the subscriber agreement is acceptable to you before using this container. âš¡

Prerequisites

Before you begin, you'll need:

  1. A place to run Docker containers with a public IP.
  2. A domain name with an A record pointing to your cluster.

Usage

Launch your backend container and note its name, then launch smashwilson/lets-nginx with the following parameters:

  • --link backend:backend to link your backend service's container to this one. (This may be unnecessary depending on Docker's networking configuration.)
  • -e EMAIL= your email address, used to register with letsencrypt.
  • -e DOMAIN= the domain name.
  • -e UPSTREAM= the name of your backend container and the port on which the service is listening.
  • -p 80:80 and -p 443:443 so that the letsencrypt client and nginx can bind to those ports on your public interface.
  • -e STAGING=1 uses the Let's Encrypt staging server instead of the production one. I highly recommend using this option to double check your infrastructure before you launch a real service. Let's Encrypt rate-limits the production server to issuing five certificates per domain per seven days, which (as I discovered the hard way) you can quickly exhaust by debugging unrelated problems!
  • -v {PATH_TO_CONFIGS}:/configs:ro specify manual configurations for select domains. Must be in the form {DOMAIN}.conf to be recognized.

Using more than one backend service

You can distribute traffic to multiple upstream proxy destinations, chosen by the Host header. This is useful if you have more than one container you want to access with https.

To do so, separate multiple corresponding values in the DOMAIN and UPSTREAM variables separated by a ;:

-e DOMAIN="domain1.com;sub.domain1.com;another.domain.net"
-e UPSTREAM="backend:8080;172.17.0.5:60;container:5000"

Caching the Certificates and/or DH Parameters

Since --links don't survive the re-creation of the target container, you'll need to coordinate re-creating the proxy container. In this case, you can cache the certificates and Diffie-Hellman parameters with the following procedure:

Do this once:

docker volume create --name letsencrypt
docker volume create --name letsencrypt-backups
docker volume create --name dhparam-cache

Then start the container, attaching the volumes you just created:

docker run --detach \
  --name lets-nginx \
  --link backend:backend \
  --env [email protected] \
  --env DOMAIN=mydomain.horse \
  --env UPSTREAM=backend:8080 \
  --publish 80:80 \
  --publish 443:443 \
  --volume letsencrypt:/etc/letsencrypt \
  --volume letsencrypt-backups:/var/lib/letsencrypt \
  --volume dhparam-cache:/cache \
  smashwilson/lets-nginx

Adjusting Nginx configuration

The entry point of this image processes the nginx.conf file in /templates and places the result in /etc/nginx/nginx.conf. Additionally, the file /templates/vhost.sample.conf will be processed once for each ;-delimited pair of values in $DOMAIN and $UPSTREAM. The result of each will be placed at /etc/nginx/vhosts/${DOMAINVALUE}.conf.

The following variable substitutions are made while processing all of these files:

  • ${DOMAIN}
  • ${UPSTREAM}

For example, to adjust nginx.conf, create that file in your new image directory with the baseline content and desired modifications. Within your Dockerfile ADD this file and it will be used to create the nginx configuration instead.

FROM smashwilson/lets-nginx

ADD nginx.conf /templates/nginx.conf

More Repositories

1

merge-conflicts

Resolve git merge conflicts in Atom
CoffeeScript
431
star
2

slack-emojinator

Bulk upload emoji into Slack
Python
329
star
3

hubot-markov

Hubot watches all, and builds a markov model from everything you say.
CoffeeScript
63
star
4

stacktrace

Atom package to navigate stacktraces.
CoffeeScript
35
star
5

pushbot

A Hubot instance that's here to protect you.
JavaScript
11
star
6

cringe

Orchestrate rolling deployments of Docker containers like it's 2005
JavaScript
8
star
7

hubot-pipe

Put some Unix in your Hubot
JavaScript
7
star
8

bdtg

Roleplaying system that's just a little metal
Makefile
7
star
9

node-watchman

Docker container based on node 8's Alpine distribution
6
star
10

segment

Most programmers, at some point, daydream about writing their own programming language. This one's mine.
C
6
star
11

devstack-ansible

Ansible playbook to set up devstack from a bare server.
6
star
12

branchtree

CLI to manage chains of pull request branches
Ruby
5
star
13

dotfiles

Settings and setup.
Ruby
5
star
14

mocha-stress

Re-run flaky Mocha tests to flush out inconsistent results
JavaScript
5
star
15

kite-shell

Electron + Docker, or Kitematic - UI
JavaScript
5
star
16

websinger

Turn your backup server into a jukebox
Ruby
5
star
17

objectlite

An object database analog to SQLite.
C
4
star
18

nested-builder

Tersely construct complex test fixture objects with the builder pattern.
TypeScript
4
star
19

hubot-quotefile

Embarrass your co-workers with their own words!
CoffeeScript
4
star
20

hubot-hammersport

It's over when there's a winner.
CoffeeScript
4
star
21

hubot-plan

Event planning with robots
JavaScript
3
star
22

hubot-greetings

Customized greetings for individual people by your Hubot.
CoffeeScript
3
star
23

hubot-roller

hubot roll (1d100)d(4d17 + 5)
JavaScript
3
star
24

strac

A Trac interface to the Smalltalk STORE version control system.
Python
2
star
25

cashmonies

Console-based, simplistic financial tracking.
Ruby
2
star
26

collab.fict.io

Web UI for the collaborative fiction editor.
JavaScript
2
star
27

pr-status

Dashboard reporting build and review status of your open pull requests
TypeScript
2
star
28

typescript-module-template

Starting point for writing npm modules in TypeScript.
TypeScript
2
star
29

collaborative-fiction

Tell stories with your friends.
Rust
2
star
30

watcher-stress

Stress-test node.js filesystem watchers
JavaScript
2
star
31

flashcards

JavaScript
1
star
32

git-engineroom-tour

Presentation introducing intermediate git concepts and usage.
CSS
1
star
33

pushbot.party

Frontend for pushbot's web interface
TypeScript
1
star
34

swiftest

Pythonic client library for OpenStack Object Storage
Python
1
star
35

az-infra

System components for Azurefire infrastructure
Python
1
star
36

loghttp

HTTP transaction logger for Golang.
Go
1
star
37

az-coordinator

Container orchestration for azurefire services
Go
1
star
38

strider-dockerfile

Dockerfile for a StriderCD server to run page builds
JavaScript
1
star
39

deconst-add-content

Quick automation for content repository maintenance.
Ruby
1
star
40

pull-request

GitHub pull request magic in Atom
JavaScript
1
star
41

ascension

Nanowrimo 2010
Ruby
1
star
42

az-example

An example service used to test az-coordinator deployment.
Ruby
1
star
43

hubot-harness

Test harness for Hubot scripts and plugins
JavaScript
1
star
44

create-fixture-repository

Quickly create git repositories in known states.
TypeScript
1
star
45

gpg-matrix

Execute select atom/github tests against a matrix of gpg versions
Ruby
1
star
46

az-nginx

nginx container to front azurefire infrastructure
Shell
1
star
47

azurefire

Source code for azurefire.net
CSS
1
star
48

docker-module-test

Ansible playbook that puts the Docker module through its paces.
Shell
1
star
49

hubot-pipe-scripts

Utility scripts for use with hubot-pipe
JavaScript
1
star
50

hubot-shellish

Slightly enhanced Shell adapter for Hubot development
JavaScript
1
star
51

music-manager

Spit and duct tape solution to shuttling music around our LAN.
Ruby
1
star
52

sprint-closer

Automate the closing of Trello sprints for the DevEx team.
Go
1
star
53

az-tls

Renew TLS certifications from Let's Encrypt via DNS verification
Python
1
star
54

dev-playbook

Ansible playbook to configure machines with a reasonable set of development tools.
1
star
55

deconst-drc-blog

Jekyll content decoupled from the developer.rackspace.com repository.
HTML
1
star
56

minimal-sinatra

A minimal Sinatra app that I use to test Docker things.
Ruby
1
star
57

apm-benchmarking

Some scripts to benchmark and smoke-test apm
JavaScript
1
star
58

or-redis-cli

Shell
1
star