FROM nginx:stable AS NGINX_SSL
ENV NGINX_CONF /etc/nginx/conf.d
WORKDIR $NGINX_CONF
RUN apt-get update \
&& apt-get install -y cron certbot python-certbot-nginx bash wget nano \
&& rm -rf /var/lib/apt/lists/* \
&& echo "PATH=$PATH" > /etc/cron.d/certbot-renew \
&& echo "@monthly certbot renew --nginx >> /var/log/cron.log 2>&1" >>/etc/cron.d/certbot-renew \
&& crontab /etc/cron.d/certbot-renew
ADD default.conf $NGINX_CONF
VOLUME /etc/letsencrypt
VOLUME /var/www/certbot
CMD [ "sh", "-c", "cron && nginx -g 'daemon off;'" ]
/etc/nginx/conf.d/default.conf
server {
listen 80;
listen [::]:80;
# listen [::]:443 ssl http2;
# listen 443 ssl http2;
# server_name autodeploy.today www.autodeploy.today; NO NEED
# SSL code
# ssl_certificate /etc/letsencrypt/live/autodeploy.today/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/autodeploy.today/privkey.pem;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location ~ /.well-known/acme-challenge {
allow all;
root /var/www/certbot;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
version: '3'
services:
webserver:
image: congttl/nginx-certbot
container_name: nginx-certbot
ports:
- 80:80
- 443:443
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
- ./certbot-etc:/etc/letsencrypt
- ./certbot_root:/var/www/certbot
links:
- hub
hub:
image: registry:2
container_name: dockerhub
ports:
- 5000:5000
environment:
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
volumes:
- ./registry_data:/data
volumes:
certbot-etc:
driver: local
certbot_root:
driver: local
registry_data:
driver: local
docker-compose up -d webserver
docker exec container_id certbot certonly --webroot --webroot-path=/var/www/certbot --agree-tos -m [email protected] --no-eff-email -n -d example.com -d www.example.com
create file /etc/nginx/conf.d/app.conf
server {
listen 443 ssl default_server;
ssl_certificate /etc/letsencrypt/live/autodeploy.today/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/autodeploy.today/privkey.pem;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location ~ /.well-known/acme-challenge {
allow all;
root /var/www/certbot;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
run
docker-compose up -d webserver and access https://example.com
Content type
Image
Digest
Size
86.9 MB
Last updated
about 5 years ago
docker pull congttl/nginx-certbot