Created
July 5, 2021 09:46
-
-
Save novogrammer/7633c0390260eb45952e7912a6cbb36f to your computer and use it in GitHub Desktop.
Dockerで環境構築を楽しつつ、シンプルにLet's Encryptを使う。DOMAINを実際のドメインに、CONTAINER_NAMEを稼働中のnginxコンテナ名に置き換える。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
docker run -it --rm \ | |
-p 80:80 \ | |
--name temp_certbot \ | |
-v "/etc/letsencrypt:/etc/letsencrypt" \ | |
-v "/var/lib/letsencrypt:/var/lib/letsencrypt" \ | |
certbot/certbot certonly \ | |
--standalone \ | |
--agree-tos \ | |
-d DOMAIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events { | |
worker_connections 16; | |
} | |
http { | |
server { | |
listen 80; | |
server_name DOMAIN; | |
location ^~ /.well-known/acme-challenge/ { | |
root /var/lib/letsencrypt; | |
} | |
} | |
server { | |
listen 443; | |
server_name DOMAIN; | |
ssl on; | |
ssl_certificate /etc/letsencrypt/live/DOMAIN/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem; | |
location / { | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
docker run -it --rm \ | |
--name temp_certbot \ | |
-v "/etc/letsencrypt:/etc/letsencrypt" \ | |
-v "/var/lib/letsencrypt:/var/lib/letsencrypt" \ | |
certbot/certbot certonly \ | |
--webroot -w /var/lib/letsencrypt \ | |
--agree-tos \ | |
--keep-until-expiring \ | |
-d DOMAIN | |
docker exec CONTAINER_NAME nginx -s reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment