Skip to content

Instantly share code, notes, and snippets.

@royingantaginting
Created February 11, 2016 08:12
Show Gist options
  • Save royingantaginting/ef413a15cb4ae8b60112 to your computer and use it in GitHub Desktop.
Save royingantaginting/ef413a15cb4ae8b60112 to your computer and use it in GitHub Desktop.
Nginx reverse proxy with automatic https certificate generation from Letsencrypt https://letsencrypt.org/.
proxy:
image: jwilder/nginx-proxy
volumes:
- ./opt/certs:/etc/nginx/certs:ro
- /etc/nginx/vhost.d
- /usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
ports:
- "80:80"
- "443:443"
restart: always
le:
image: jrcs/letsencrypt-nginx-proxy-companion
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./opt/certs:/etc/nginx/certs:rw
volumes_from:
- proxy
restart: always
@royingantaginting
Copy link
Author

Then start any containers you want to be proxied with a env var VIRTUAL_HOST=subdomain.youdomain.com. To use the Let's Encrypt service to automatically create a valid certificate for virtual host(s). Set the following environment variables to automatically create a valid certificate
LETSENCRYPT_HOST
LETSENCRYPT_EMAIL
The LETSENCRYPT_HOST variable most likely needs to be the same as the VIRTUAL_HOST variable and must be publicly reachable domains. Specify multiple hosts with a comma delimiter. The LETSENCRYPT_EMAIL variable must be a valid email address

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment