Snippet – Nginx Wildcard Subdomain

This snippet works with Letsencrypt Wildcard certificates! Specify -d *.domain.com to install the certificate when using certbot.

Insert into server block. Change domain.com to correct domain.

server_name ~^(?<subdomain>.+)\.domain\.com$; 

root /var/www/html/domain,com/$subdomain/htdocs;

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *