The LinuxServer.io team brings you another container release featuring :-
Find us at:
#linuxserver.io. Our primary support channel is Discord.Letsencrypt sets up an Nginx webserver and reverse proxy with php support and a built-in letsencrypt client that automates free SSL server certificate generation and renewal processes. It also contains fail2ban for intrusion prevention.
Our images support multiple architectures such as x86-64, arm64 and armhf. We utilise the docker manifest for multi-platform awareness. More information is available from docker here and our announcement here.
Simply pulling linuxserver/letsencrypt should retrieve the correct image for your arch, but you can also pull specific arch images via tags.
The architectures supported by this image are:
| Architecture | Tag |
|---|---|
| x86-64 | amd64-latest |
| arm64 | arm64v8-latest |
| armhf | arm32v7-latest |
Here are some example snippets to help you get started creating a container.
docker create \
--name=letsencrypt \
--cap-add=NET_ADMIN \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=Europe/London \
-e URL=yourdomain.url \
-e SUBDOMAINS=www, \
-e VALIDATION=http \
-e DNSPLUGIN=cloudflare `#optional` \
-e DUCKDNSTOKEN=<token> `#optional` \
-e EMAIL=<e-mail> `#optional` \
-e DHLEVEL=2048 `#optional` \
-e ONLY_SUBDOMAINS=false `#optional` \
-e EXTRA_DOMAINS=<extradomains> `#optional` \
-e STAGING=false `#optional` \
-p 443:443 \
-p 80:80 `#optional` \
-v </path/to/appdata/config>:/config \
--restart unless-stopped \
linuxserver/letsencrypt
Compatible with docker-compose v2 schemas.
---
version: "2"
services:
letsencrypt:
image: linuxserver/letsencrypt
container_name: letsencrypt
cap_add:
- NET_ADMIN
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
- URL=yourdomain.url
- SUBDOMAINS=www,
- VALIDATION=http
- DNSPLUGIN=cloudflare #optional
- DUCKDNSTOKEN=<token> #optional
- EMAIL=<e-mail> #optional
- DHLEVEL=2048 #optional
- ONLY_SUBDOMAINS=false #optional
- EXTRA_DOMAINS=<extradomains> #optional
- STAGING=false #optional
volumes:
- </path/to/appdata/config>:/config
ports:
- 443:443
- 80:80 #optional
restart: unless-stopped
Container images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate <external>:<internal> respectively. For example, -p 8080:80 would expose port 80 from inside the container to be accessible from the host's IP on port 8080 outside the container.
| Parameter | Function |
|---|---|
-p 443 | Https port |
-p 80 | Http port (required for http validation only) |
-e PUID=1000 | for UserID - see below for explanation |
-e PGID=1000 | for GroupID - see below for explanation |
-e TZ=Europe/London | Specify a timezone to use EG Europe/London. |
-e URL=yourdomain.url | Top url you have control over (customdomain.com if you own it, or customsubdomain.ddnsprovider.com if dynamic dns). |
-e SUBDOMAINS=www, | Subdomains you'd like the cert to cover (comma separated, no spaces) ie. www,ftp,cloud. For a wildcard cert, set this exactly to wildcard (wildcard cert is available via dns and duckdns validation only) |
-e VALIDATION=http | Letsencrypt validation method to use, options are http, tls-sni, dns or duckdns (dns method also requires DNSPLUGIN variable set) (duckdns method requires DUCKDNSTOKEN variable set, and the SUBDOMAINS variable set to wildcard). |
-e DNSPLUGIN=cloudflare | Required if VALIDATION is set to dns. Options are cloudflare, cloudxns, digitalocean, dnsimple, dnsmadeeasy, google, luadns, nsone, ovh, rfc2136 and route53. Also need to enter the credentials into the corresponding ini file under /config/dns-conf. |
-e DUCKDNSTOKEN=<token> | Required if VALIDATION is set to duckdns. Retrieve your token from https://www.duckdns.org |
-e EMAIL=<e-mail> | Optional e-mail address used for cert expiration notifications. |
-e DHLEVEL=2048 | Dhparams bit value (default=2048, can be set to 1024 or 4096). |
-e ONLY_SUBDOMAINS=false | If you wish to get certs only for certain subdomains, but not the main domain (main domain may be hosted on another machine and cannot be validated), set this to true |
-e EXTRA_DOMAINS=<extradomains> | Additional fully qualified domain names (comma separated, no spaces) ie. extradomain.com,subdomain.anotherdomain.org |
-e STAGING=false | Set to true to retrieve certs in staging mode. Rate limits will be much higher, but the resulting cert will not pass the browser's security test. Only to be used for testing purposes. |
-v /config | All the config files including the webroot reside here. |
When using volumes (-v flags) permissions issues can arise between the host OS and the container, we avoid this issue by allowing you to specify the user PUID and group PGID.
Ensure any volume directories on the host are owned by the same user you specify and any permissions issues will vanish like magic.
In this instance PUID=1000 and PGID=1000, to find yours use id user as below:
$ id username
uid=1000(dockeruser) gid=1000(dockergroup) groups=1000(dockergroup)
http validation, port 80 on the internet side of the router should be forwarded to this container's port 80tls-sni validation, port 443 on the internet side of the router should be forwarded to this container's port 443dns validation, make sure to enter your credentials into the corresponding ini file under /config/dns-conf
duckdns validation, set the SUBDOMAINS variable to wildcard, and set the DUCKDNSTOKEN variable with your duckdns token. Due to a limitation of duckdns, the resulting cert will only cover the sub-subdomains (ie. *.yoursubdomain.duckdns.org) but will not cover yoursubdomain.duckdns.org. Therefore, it is recommended to use a sub-subdomain like www.yoursubdomain.duckdns.org for subfolders. You can use our duckdns image to update your IP on duckdns.org.--cap-add=NET_ADMIN is required for fail2ban to modify iptablesURL will be yoursubdomain.duckdns.org and the SUBDOMAINS can be www,ftp,cloud with http validation, or wildcard with dns validation.https://yourdomain.url to access the default homepage (http access through port 80 is disabled by default, you can enable it by editing the default site config at /config/nginx/site-confs/default)./config/log/letsencrypt to see why the renewals have been failing. It is recommended to input your e-mail in docker parameters so you receive expiration notices from letsencrypt in those circumstances.docker exec -it letsencrypt htpasswd -c /config/nginx/.htpasswd <username>.htpasswd. For the first user, use the above command, for others, use the above command without the -c flag, as it will force deletion of the existing .htpasswd and creation of a new one/config/nginx/site-confs/default. Feel free to modify this file, and you can add other conf files to this directory. However, if you delete the default file, a new default will be created on container start.README.md file under /config/nginx/proxy_confs for instructions on how to enable them. The preset confs reside in and get imported from this repo.add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
This will ask Google et al not to index and list your site. Be careful with this, as you will eventually be de-listed if you leave this line in on a site you wish to be present on search engines-v /path-to-le-config:/le-ssl) and in the other containers, use the cert location /le-ssl/keys/letsencrypt/etc/letsencrypt that resides under /config in other containers (ie. -v /path-to-le-config/etc/letsencrypt:/le-ssl) and in the other containers, use the cert location /le-ssl/live/<your.domain.url>/ (This is more secure because the first method shares the entire letsencrypt config folder with other containers, including the www files, whereas the second method only shares the ssl certs)cert.pem, chain.pem, fullchain.pem and privkey.pem, which are generated by letsencrypt and used by nginx and various other appsprivkey.pfx, a format supported by Microsoft and commonly used by dotnet apps such as Emby Server (no password)priv-fullchain-bundle.pem, a pem cert that bundles the private key and the fullchain, used by apps like ZNC/config/fail2ban/jail.local.conf files, create .local files with the same name and edit those because .conf files get overwritten when the actions and filters are updated. .local files will append whatever's in the .conf files (ie. nginx-http-auth.conf --> nginx-http-auth.local)docker exec -it letsencrypt fail2ban-client statusdocker exec -it letsencrypt fail2ban-client status <jail name>docker exec -it letsencrypt fail2ban-client set <jail name> unbanip <IP>docker exec -it letsencrypt /bin/bashdocker logs -f letsencryptdocker inspect -f '{{ index .Config.Labels "build_version" }}' letsencryptdocker inspect -f '{{ index .Config.Labels "build_version" }}' linuxserver/letsencryptMost of our images are static, versioned, and require an image update and container recreation to update the app inside. With some exceptions (ie. nextcloud, plex), we do not recommend or support updating apps inside the container. Please consult the Application Setup section above to see if it is recommended for the image.
Below are the instructions for updating containers:
docker pull linuxserver/letsencryptdocker stop letsencryptdocker rm letsencrypt/config folder and settings will be preserved)docker start letsencryptdocker image prunedocker-compose pull
docker-compose pull letsencryptdocker-compose up -d
docker-compose up -d letsencryptdocker image prunedocker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--run-once letsencrypt
Note: We do not endorse the use of Watchtower as a solution to automated updates of existing Docker containers. In fact we generally discourage automated updates. However, this is a useful tool for one-time manual updates of containers where you have forgotten the original parameters. In the long term, we highly recommend using Docker Compose.
docker image pruneIf you want to make local modifications to these images for development purposes or just to customize the logic:
git clone https://github.com/linuxserver/docker-letsencrypt.git
cd docker-letsencrypt
docker build \
--no-cache \
--pull \
-t linuxserver/letsencrypt:latest .
The ARM variants can be built on x86_64 hardware using multiarch/qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static:register --reset
Once registered you can define the dockerfile to use with -f Dockerfile.aarch64.
feature of up to 8 minute random delay.linuxserver/reverse-proxy-confs, update baseimage packages during buildVALIDATION parameter added for choosing letsencrypt validation methods, including dns through official plugins. HTTPVAL is deprecated. STAGING parameter added for testing. Backwards compatibility for the short term. Since tls-sni is disabled by letsencrypt, most users will have to change their settings and adopt the new parameters within the next 90 days. Reorganized the nginx default config, split ssl settings into new ssl.conf/config/fail2ban/action.d/iptables-common.local and restarting the container after updating the image--privileged is no longer required as long as --cap-add=NET_ADMIN is added, instructions modified accordingly, disabled fail2ban ipv6 actions due to requiring access to host kernel modulesContent type
Image
Digest
Size
100.9 MB
Last updated
about 7 years ago
docker pull cozza38/docker-letsencrypt