Configure FTPS (FTP over SSL) with Let's Encrypt
masterTo use FTPS, you must provide paths to a valid SSL certificate and private key via TLS_CERT and TLS_KEY environment variables.
Steps:
- Ensure port 80 is available for Certbot's standalone mode.
- Issue a certificate using Certbot.
- Mount the certificate directory as read-only (
:ro) to the FTP container. - Set the
TLS_CERTandTLS_KEYenvironment variables to the paths of yourfullchain.pemandprivkey.pem.
Note: Remember to renew certificates every 3 months using certbot renew.
# 1. Issue certificate
mkdir -p /etc/letsencrypt
docker run -it --rm \
-p 80:80 \
-v "/etc/letsencrypt:/etc/letsencrypt" \
certbot/certbot certonly \
--standalone \
--preferred-challenges http \
-n --agree-tos \
--email i@delfer.ru \
-d ftp.site.domain
# 2. Run FTP server with TLS
docker run -d \
--name ftp \
-p "21:21" \
-p 21000-21010:21000-21010 \
-v "/etc/letsencrypt:/etc/letsencrypt:ro" \
-e USERS="one|1234" \
-e ADDRESS=ftp.site.domain \
-e TLS_CERT="/etc/letsencrypt/live/ftp.site.domain/fullchain.pem" \
-e TLS_KEY="/etc/letsencrypt/live/ftp.site.domain/privkey.pem" \
delfer/alpine-ftp-server