Sign inSign up

ukjaiswal/nginx-certbot

By ukjaiswal

Updated almost 2 years ago

Create Letsencrypt certificate using Certbot

Image
Networking
Web servers
Operating systems
0

1.0K

ukjaiswal/nginx-certbot repository overview

About

Simple docker image to generate LetsEncrypt certificates.

Check the simple Dockerfile at https://github.com/ukjaiswal/nginx-certbot to rebuild the image from scratch.

Example

Sample docker command

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.

Sample nginx-custom-domain.conf file for a static site

server {
    listen 80;
    server_name custom.domain.com;
    root /usr/share/nginx/html;
    index index.html index.htm;

location / {
        try_files $uri $uri/ =404;
    }

}

Sample nginx-custom-domain.conf file for a reverse proxy to an application running on port 3000

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

The certbot command

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

Tag summary

Content type

Image

Digest

sha256:8121ba7e8

Size

85.1 MB

Last updated

almost 2 years ago

docker pull ukjaiswal/nginx-certbot