

Wildcard Let's Encrypt SSL for One-Click LAMP
source link: https://www.vultr.com/docs/wildcard-lets-encrypt-ssl-for-one-click-lamp
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Using a Different System?
- Let's Encrypt on cPanel
- Let's Encrypt on Plesk
- Installing Let's Encrypt on DirectAdmin
- Using Let's Encrypt on OpenBSD 6.1
- Install Nginx, Wordpress and Let's Encrypt in Minutes With EasyEngine on Debian 8 or Ubuntu 16.04
- How to Install Let's Encrypt SSL on CentOS 7 Running Apache Web Server
- Install Let's Encrypt SSL on One-Click WordPress
- Install Let's Encrypt SSL on Ubuntu with Apache or Nginx
- How to Configure a Let's Encrypt TLS Certificate for Windows Remote Desktop
- Install a Free Let's Encrypt TLS/SSL Certificate on a CentOS 7 LEMP Server with Certbot
- Use a Wildcard Let's Encrypt Certificate with Vultr Load Balancer
Introduction
Let's Encrypt is an automated, open certificate authority that offers free TLS/SSL certificates for the public's benefit. The service is provided by the Internet Security Research Group (ISRG). This tutorial describes how to install a wildcard Let's Encrypt SSL certificate using certbot and lego on the Vultr One-Click LAMP app using Vultr DNS.
After completing this tutorial, the website will have a valid wildcard certificate, and the web server will redirect all HTTP requests to HTTPS. The lego method is preferred because certbot does not support automatic updates with Vultr DNS.
Prerequisite Steps
Make sure you have all of the following items complete before proceeding with this tutorial.
Deploy a new Vultr One-Click LAMP app (Ubuntu 18.04).
Add a domain to Vultr DNS. This tutorial will use the domain example.com and IP address 192.0.2.123. At a minimum, assuming your server is named www, your DNS will look like this:
Enable your Vultr API key.
Allow the IP address of your server in the API access control.
SSH to your server as root.
- Update the server, following the Vultr best practices guide.
Install Wildcard SSL with Lego
The lego installation method allows for automatic updates. Choose this method if you plan to update your certificate before it expires each 90 days automatically.
1. Install lego.
The lego version in the Ubuntu 18.04 repository is old and does not support the DNS challenge method required for wildcard DNS.
Install the latest release from GitHub.
Manually download from here:
https://github.com/go-acme/lego/releases
Or, automatically download the latest:
# curl -Ls https://api.github.com/repos/go-acme/lego/releases/latest | \ grep browser_download_url | grep linux_amd64 | cut -d '"' -f 4 | \ wget -i -
Extract
lego
.# tar xf lego_v*_linux_amd64.tar.gz
Move lego to /usr/local/sbin.
# mv lego /usr/local/sbin/
Verify lego is on your path and the correct version.
# lego -v lego version 3.7.0 linux/amd64
2. Get a new certificate.
- Retrieve your API Key from https://my.vultr.com/settings/#settingsapi
Create the get-cert.sh script in /usr/local/sbin.
# nano /usr/local/sbin/get-cert.sh
Paste the contents below into get-cert.sh.
- Replace the example API key with your key.
- Replace the example email with your address.
Replace example.com with your domain. The domain is listed twice, once for the bare domain, and once for the wildcard. If you are not using the bare domain URL (https://example.com), you can omit that value and only request the wildcard.
#!/bin/sh export VULTR_API_KEY=xxxx_EXAMPLE_API_KEY_xxxx export VULTR_HTTP_TIMEOUT=60 export VULTR_POLLING_INTERVAL=60 export VULTR_PROPAGATION_TIMEOUT=300 export VULTR_TTL=300 lego --dns vultr \ --domains *.example.com \ --domains example.com \ --email [email protected] \ --path="/etc/letsencrypt/example.com" \ --accept-tos run
Make the script executable.
# chmod +x /usr/local/sbin/get-cert.sh
Run the script.
# /usr/local/sbin/get-cert.sh
Verify the certificates were issued.
# ls -l /etc/letsencrypt/example.com/certificates/ total 16 -rw------- 1 root root 3307 May 20 14:15 _.example.com.crt -rw------- 1 root root 1648 May 20 14:15 _.example.com.issuer.crt -rw------- 1 root root 230 May 20 14:15 _.example.com.json -rw------- 1 root root 288 May 20 14:15 _.example.com.key
3. Install SSL Certificate for Apache
Archive the existing Apache certificate.
# mv /etc/apache2/ssl/server.crt /etc/apache2/ssl/server.crt.old # mv /etc/apache2/ssl/server.key /etc/apache2/ssl/server.key.old
Link the Apache certificate to the Let's Encrypt certificate.
# ln -s /etc/letsencrypt/example.com/certificates/_.example.com.crt /etc/apache2/ssl/server.crt # ln -s /etc/letsencrypt/example.com/certificates/_.example.com.key /etc/apache2/ssl/server.key
Restart Apache.
# service apache2 restart
Navigate to your website in a browser and verify that the certificate is correct and issued to the wildcard domain name.
Set up automatic certificate renewal
- Retrieve your API Key from https://my.vultr.com/settings/#settingsapi
Create the renew-cert.sh script in /usr/local/sbin.
# nano /usr/local/sbin/renew-cert.sh
Paste the contents below into renew-cert.sh.
- Replace the example API key with your own.
Replace the example email address and domain names with your own.
#!/bin/sh export VULTR_API_KEY=xxxx_EXAMPLE_API_KEY_xxxx export VULTR_HTTP_TIMEOUT=60 export VULTR_POLLING_INTERVAL=60 export VULTR_PROPAGATION_TIMEOUT=300 export VULTR_TTL=300 lego --dns vultr \ --domains *.example.com \ --domains example.com \ --email [email protected] \ --path="/etc/letsencrypt/example.com" \ --accept-tos renew
Make the script executable.
# chmod +x /usr/local/sbin/renew-cert.sh
Edit the crontab.
# crontab -e
Add the following line to crontab. Adjust the schedule as needed. The following example will run at 04:05 a.m. each Monday.
5 4 * * 1 /usr/local/sbin/renew-cert.sh 2> /dev/null
Summary
You have completed wildcard SSL installation using lego. Your server will automatically check the certificate each Monday and renew the certificate before it expires.
Install Wildcard SSL with Certbot
The certbot procedure is manual. Automatic renewal with certbot is not possible with Vultr DNS. If you want to renew automatically, the Lego method is preferred.
1. Install certbot
Install certbot with apt.
# apt update && apt install certbot -y
2. Request Wildcard Certificate
Run certbot with the certonly and --manual options. Replace example.com with your domain. The domain is listed twice, once for the bare domain, and once for the wildcard. If you are not using the bare domain URL (https://example.com), you can omit that value and only request the wildcard.
# certbot certonly --manual \
-d *.example.com \
-d example.com \
-m [email protected] \
--preferred-challenges dns --agree-tos \
--no-eff-email --manual-public-ip-logging-ok
The certbot wizard will print instructions to add a TXT record to your domain's DNS. For example:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.example.com with the following value:
U5Y4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxN914
Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue
The certbot wizard will pause at this point. Do not press ENTER until you've completed the DNS steps below.
Use a web browser to:
- Navigate to your DNS provider.
- Add the TXT record shown by certbot to your domain's DNS.
Test that the TXT record is propagated properly. Popular ways to test the TXT record include dig
and the dnschecker.org website. Replace example.com with your name in these examples:
To test with
dig
, open another terminal window and lookup the domain record, replacing example.com with your domain. Verify that the value returned is correct.# dig +short TXT _acme-challenge.example.com "U5Y4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxN914"
To use dnschecker.org, navigate to the URL, replacing example.com with your domain. Verify that the value returned is correct.
https://dnschecker.org/#TXT/_acme-challenge.example.com
In the propagation test, when you see the correct TXT record, return to the certbot wizard and press ENTER to continue. If the certificate challenge succeeds, certbot will report the location of the new certificate files.
...
Cleaning up challenges
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/example.com/privkey.pem
3. Install Certificate for Apache
Archive the existing Apache certificate.
# mv /etc/apache2/ssl/server.crt /etc/apache2/ssl/server.crt.old
# mv /etc/apache2/ssl/server.key /etc/apache2/ssl/server.key.old
Link the Let's Encrypt certificate where Apache expects to find it.
# ln -s /etc/letsencrypt/live/example.com/fullchain.pem /etc/apache2/ssl/server.crt
# ln -s /etc/letsencrypt/live/example.com/privkey.pem /etc/apache2/ssl/server.key
Restart Apache.
# service apache2 restart
Using a web browser, navigate to your website, and verify the certificate is correct.
Summary
You have completed wildcard SSL installation using certbot. You will need to renew the certificate before it expires manually.
Want to contribute?
You could earn up to $600 by adding new articles
Recommend
-
10
From our blog Nov 6, 2020 Standing on O...
-
12
使用Let's Encrypt创建SSL证书 TianFang 相濡以沫,不如相忘于江湖 随笔 - 824 文章 - 5 评论 - 923 阅读 - 396...
-
8
Tutorial How To Create Let's Encrypt Wildcard Certificates with Certbot Security
-
9
Let's Encrypt SSL certificate overview Overview Let's Encrypt is a new Certificate Authority (CA) that offers FREE SSL certificates that are just as secure as paid...
-
13
免费SSL证书Let's Encrypt的替代:SSL.com随着 HTTPS 在 Web 上的使用不断增加,我们需要颁发证书的证书颁发机构提供更多支持,Let's Encrypt提供的免费SSL证书,但如果我们想加密整个 Web,我们不能依...
-
9
V2EX › 程序员 练手撸了个 Let's encrypt 的 SSL 证书签发服务 neurocomputing ·...
-
9
Configuring NGINX for SSL with Let's Encrypt By Joel Berger o...
-
7
Using a Different System? Let...
-
7
Not FoundYou just hit a route that doesn't exist... the sadness.LoginRadius empowers businesses to deliver a delightful customer experience and win customer trust. Using the LoginRadius Identity...
-
9
Let's Encrypt 如何配置Let's Encrypt SSL证书 Web进行安全通信依赖于HTTPS,这需要使用数字证书,以便浏览器验证Web服务器的身份,比如说...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK