Skip to content

Instantly share code, notes, and snippets.

@carsondarling
Created August 26, 2016 19:16
Show Gist options
  • Save carsondarling/2fa6f64072e1a56b065b0f8cd5ba386c to your computer and use it in GitHub Desktop.
Save carsondarling/2fa6f64072e1a56b065b0f8cd5ba386c to your computer and use it in GitHub Desktop.
version: '2'
services:
# The proxy is responsible for running an nginx instance and routing to each
# container that has a VIRTUAL_HOST environment variable setup. We are
# exposing both ports 80 and 443, so that HTTPS redirection will happen.
proxy:
image: jwilder/nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- /root/certs:/etc/nginx/certs:ro
- /etc/nginx/vhost.d
- /usr/share/nginx/html
# The SSL container is responsible for fetching certificates from Let's
# Encrypt and providing them to the proxy container above.
proxy-ssl:
image: jrcs/letsencrypt-nginx-proxy-companion
volumes:
- /root/certs:/etc/nginx/certs:rw
- /var/run/docker.sock:/var/run/docker.sock:ro
volumes_from:
- proxy
# This container is a simple hello world web app. By setting its environment
# variables, the nginx proxy container will automatically register a virtual
# host for it, and an SSL certificate will be generated.
demo_server:
image: dockercloud/hello-world
restart: always
expose:
- 80
environment:
VIRTUAL_HOST: "<your domain here>"
LETSENCRYPT_HOST: "<your domain here>"
LETSENCRYPT_EMAIL: "<your email here>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment