-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.nginx.j2
More file actions
88 lines (68 loc) · 2.62 KB
/
Makefile.nginx.j2
File metadata and controls
88 lines (68 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Set a special docker-compose file for all the operations
COMPOSE := docker compose
CERT_PATH=/etc/letsencrypt/live/{{ domain_name }}
DATA_PATH=./data/certbot
SSL_NGINX_CONF_URL=https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf
SSL_DHPARAMS_URL=https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem
echo:
"This is a first dummy target, so you don't accidentally run something :)"
nginx/recreate:
$(COMPOSE) up --force-recreate -d nginx
certbot/renew:
$(COMPOSE) run certbot renew
$(COMPOSE) restart nginx
certbot/list:
$(COMPOSE) run certbot certificates
certbot/init-staging: \
certbot/download-initial-parameters \
certbot/create-dummy-certificate \
nginx/recreate \
certbot/delete-dummy-certificate \
certbot/create-staging-certificate
certbot/download-initial-parameters:
@echo "### Downloading recommended TLS parameters ... "
mkdir -p "$(DATA_PATH)/conf"
curl -s $(SSL_NGINX_CONF_URL) > "$(DATA_PATH)/conf/options-ssl-nginx.conf"
curl -s $(SSL_DHPARAMS_URL) > "$(DATA_PATH)/conf/ssl-dhparams.pem"
certbot/create-dummy-certificate:
@echo "### Creating a dummy certificate for {{ domain_name }}"
mkdir -p "$(DATA_PATH)/conf/live/{{ domain_name }}"
$(COMPOSE) run --rm --entrypoint "\
openssl req -x509 -nodes -newkey rsa:{{ letsencrypt_rsa_key_size }} \
-days 1 \
-keyout '$(CERT_PATH)/privkey.pem' \
-out '$(CERT_PATH)/fullchain.pem' \
-subj '/CN=localhost'" \
certbot
certbot/delete-dummy-certificate:
@echo "### Deleting dummy certificate for {{ domain_name }} ..."
$(COMPOSE) run --rm --entrypoint "\
rm -rf /etc/letsencrypt/live/{{ domain_name }} && \
rm -rf /etc/letsencrypt/archive/{{ domain_name }} && \
rm -rf /etc/letsencrypt/renewal/{{ domain_name }}.conf" \
certbot
certbot/create-staging-certificate:
# First regenerate the certificate
$(COMPOSE) run certbot certonly \
--staging \
--webroot -w /var/www/certbot \
--email "{{ letsencrypt_email }}" \
-d "{{ domain_name }}" \
--rsa-key-size "{{ letsencrypt_rsa_key_size }}" \
--agree-tos \
--force-renewal
# And then restart nginx....
$(COMPOSE) exec nginx nginx -s reload
certbot/force-reissue-PROD-certificate:
# First regenerate the certificate
$(COMPOSE) run certbot certonly \
--force-renewal \
--webroot -w /var/www/certbot \
--email "{{ letsencrypt_email }}" \
-d "{{ domain_name }}" \
--rsa-key-size "{{ letsencrypt_rsa_key_size }}" \
--agree-tos \
--force-renewal
# And then restart nginx....
$(COMPOSE) exec nginx nginx -s reload
certbot/upgrade-to-prod: certbot/force-reissue-PROD-certificate