-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #42. Dig is used to monitor for an A-Record. Once detected, we use Certbot to obtain a certificate.
- Loading branch information
Showing
12 changed files
with
184 additions
and
40 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
while sleep 60 | ||
do | ||
if dig $DOMAIN | grep $IP; then | ||
mv /etc/nginx/conf.d/redirect_domain.conf.disabled /etc/nginx/conf.d/redirect_domain.conf | ||
systemctl restart nginx | ||
exit 0 | ||
fi | ||
echo "DNS entry (A record for $DOMAIN to $IP) not found yet..." | ||
done | ||
exit 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Permissions | ||
|
||
Although the AWS template contains a user `certbot`, the actual Certbot, systemd | ||
services and cron jobs using it all run as root. This is because they need to | ||
modify nginx configuration files both to install the certificate and, more importantly, | ||
to pass the domain control verification challenge. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Harden, Diffie-Hellman Parameters, wait for A-Record, request and install first certificate. | ||
After=network.target | ||
ConditionPathExists=/etc/nginx/conf.d/https_upgrade.conf.disabled | ||
ConditionPathExists=!/home/cert/.failed | ||
|
||
[Service] | ||
EnvironmentFile=/root/.env | ||
ExecStart=/usr/local/src/matreon/vendor/certbot/first_certificate.sh | ||
|
||
Type=simple | ||
Restart=on-failure | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
if [ ! -f /etc/ssl/certs/dhparam.pem ]; then | ||
openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048 | ||
fi | ||
|
||
while sleep 60 | ||
do | ||
if dig $DOMAIN | grep $IP; then | ||
if /bin/certbot --nginx -m $EMAIL --agree-tos -n --domains $DOMAIN; then | ||
mv /etc/nginx/conf.d/https_upgrade.conf.disabled /etc/nginx/conf.d/https_upgrade.conf | ||
>/etc/nginx/conf.d/matreon/listen | ||
systemctl restart nginx | ||
exit 0 | ||
else | ||
echo "Failed to register or install certificate, remove /home/certbot/.failed and restart the service to try again." | ||
touch /home/cert/.failed | ||
exit 1 | ||
fi | ||
fi | ||
echo "DNS entry (A record for $DOMAIN to $IP) not found yet..." | ||
done | ||
exit 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=Wait for A-record and enables redirect | ||
After=network.target | ||
ConditionPathExists=/etc/nginx/conf.d/redirect_domain.conf.disabled | ||
|
||
[Service] | ||
EnvironmentFile=/root/.env | ||
ExecStart=/usr/local/src/matreon/vendor/AWS/redirect_domain.sh | ||
|
||
Type=simple | ||
Restart=on-failure | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
server { | ||
listen 80; | ||
return 301 https://$host$request_uri; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Removed by first-certificate.service once HTTPS is enabled (at the same time | ||
# the request upgrader is enabled) | ||
listen 80; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# File is replaced during provisioning | ||
server_name _; |
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