Create Letsencrypt certificate using Certbot
1.0K
Simple docker image to generate LetsEncrypt certificates.
Check the simple Dockerfile at https://github.com/ukjaiswal/nginx-certbot to rebuild the image from scratch.
docker run -it --rm --name nginx-certbot1 -v /tmp/letsencrypt:/etc/letsencrypt -p 80:80 nginx-certbot bash
One can adjust the path to desired directories.
server {
listen 80;
server_name custom.domain.com;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}
server {
server_name custom.domain.com;
proxy_set_header x-forwarded-proto "https";
server_tokens off;
ssl_protocols TLSv1.2 TLSv1.3;
# add_header Content-Security-Policy "default-src 'self'; img-src *";
add_header X-Frame-Options "SAMEORIGIN";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
location / {
proxy_pass http://application:3000;
proxy_set_header Host $host;
}
listen 80;
}
The above file can be saved as /etc/nginx/conf.d/nginx-custom-domain.conf inside the docker container
certbot -d host.example.com
The certificates would be saved in the folder /tmp/letsencrypt in the host and in the folder /etc/letsencrypt inside the container
Content type
Image
Digest
sha256:8121ba7e8…
Size
85.1 MB
Last updated
almost 2 years ago
docker pull ukjaiswal/nginx-certbot