How to obtain a wildcard ssl certificate from Let’s Encrypt and setup Nginx to use wildcard subdomain

Utkarsh Verma
May 17, 2018 · 2 min read

Recently Let’s Encrypt officially started issuing wildcard ssl certificate using Automated Certificate Management Environment (ACME) V2 endpoint.

This is the continuation of the article that I have written before.

Let’s begin by

  • Installing Let’s Encrypt on Ubuntu 16.04 server
  • Installing Nginx
  • Setup DNS to serve all the subdomains
  • Obtaining wildcard ssl certificate from Let’s Encrypt
  • Configuring Nginx to serve wildcard subdomains
  • Test and restart Nginx

Installing Let’s Encrypt on Ubuntu 16.04 server

Installing Nginx

Setup DNS to serve all the subdomains

  • Create a custom A record, HOST * POINTS TO: Your IP Address(Eg: 103.21.0.108)
  • Create a custom A record, HOST @ POINTS TO: Your IP Address(Eg: 103.21.0.108)
  • Add a CNAME record, HOST www POINTS TO @ this refers to your IP address.

Obtaining wildcard ssl certificate from Let’s Encrypt

Note:- Replace example.com with your domain name

Deploy a DNS TXT record provided by Let’s Encrypt certbot after running the above command

Configuring Nginx to serve wildcard subdomains

  • Create a config file sudo touch /etc/nginx/sites-available/example.com
  • Open the file sudo vi /etc/nginx/sites-available/example.com
  • Add the following code in the file

Note:- Replace example.com with your domain name.

The above server block is listening on port 80 and redirects the request to the server block below it that is listening on port 443.

Test and restart Nginx

  • Test Nginx configuration using sudo nginx -t
  • If it’s success reload Nginx using sudo /etc/init.d/nginx reload

Nginx is now setup to handle wildcard subdomains.

Good luck with building your application.
Do let me know if you face any issues during the configuration :)
I am available at Utkarsh Verma

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store