Skip to content

Nginx with automatic let's encrypt (docker image)

License

Notifications You must be signed in to change notification settings

theruziev/nginx-le

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NGINX-LE - Nginx web and proxy with automatic let's encrypt Docker Automated build

Simple nginx image (alpine based) with integrated Let's Encrypt support.

How to use

  • get docker-compose.yml and change things:
    • set timezone to your local, for example TZ=UTC. For more timezone values check /usr/share/zoneinfo directory
    • set LETSENCRYPT=true if you want automatic certificate install and renewal
    • LE_EMAIL should be your email and LE_FQDN for domain
    • for multiple FQDNs you can pass comma-separated list, like LE_FQDN=aaa.example.com,bbb.example.com
    • alternatively set LETSENCRYPT to false and pass your own cert in SSL_CERT, key in SSL_KEY and SSL_CHAIN_CERT
    • use provided etc/service-example.conf to make your own etc/service.conf. Keep ssl directives as is:
      ssl_certificate SSL_CERT;
      ssl_certificate_key SSL_KEY;
      ssl_trusted_certificate SSL_CHAIN_CERT;
  • make sure volumes in docker-compose.yml changed to your service config
  • you can map multiple custom config files in compose for any service*.conf (see docker-compose.yml for service2.conf)
  • pull image - docker-compose pull
  • if you don't want pre-built image, make you own. docker-compose build will do it
  • start it docker-compose up

Some implementation details

Important: provided nginx.conf handles http->https redirect automatically, no need to add it into your custom servcie.conf. In case if you need a custom server on http (:80) port, make sure you handle /.well-known/ path needed for LE challenge.

  • image uses alpine's certbot package.
  • script/entrypoint.sh requests LE certificate and will refresh every 10 days in case if certificate is close to expiration (30day)
  • script/le.sh gets SSL
  • nginx-le on docker-hub
  • A+ overall rating on ssllabs

ssllabs

Alternatives

  • Træfik HTTP reverse proxy and load balancer. Supports Let's Encrypt directly.
  • Caddy supports Let's Encrypt directly.
  • leproxy small and nice (stand alone) https reverse proxy with automatic Letsencrypt
  • bunch of others

Examples

  • Reverse proxy for WebRTC solutions, where you need multiple ports on one domain to reach different services behind your nginx-le container.

About

Nginx with automatic let's encrypt (docker image)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 92.9%
  • Dockerfile 7.1%