Wildcard DNS allows a single DNS record to cover all subdomains — essential for SaaS applications where each customer gets their own subdomain.
Step 1 — Add Wildcard DNS Record
Type: A
Name: *.yourdomain.com
Content: YOUR_SERVER_IP
Step 2 — Configure Nginx
server {
listen 443 ssl;
server_name *.yourdomain.com;
set $subdomain "";
if ($host ~* ^(.+)\.yourdomain\.com$) {
set $subdomain $1;
}
root /var/www/app/public;
location / {
try_files $uri $uri/ /index.php?subdomain=$subdomain&$args;
}
}
Step 3 — Wildcard SSL Certificate
sudo certbot certonly --manual --preferred-challenges dns -d yourdomain.com -d *.yourdomain.com --server https://acme-v02.api.letsencrypt.org/directory
Conclusion
Wildcard DNS enables scalable multi-tenant architectures. Our team configures wildcard DNS and SSL for SaaS applications.
Comments