How to Configure SSL Certificates for Multiple Domains: Practical Steps & Best Practices
SSL for multiple domains doesnt have to be a headache — this practical guide breaks down SANs, wildcards, SNI, and server setup so you can secure every hostname with confidence. Follow clear steps and best practices like choosing the right keys and enabling OCSP stapling to avoid mixed-content warnings and handshake failures.
Managing SSL/TLS certificates for multiple domains is a common challenge for site owners, developers, and enterprises hosting several services on the same server or across a cluster. Properly configuring certificates affects both security and user trust, and poor configuration can lead to mixed-content warnings, handshake failures, or performance regressions. This article explains the underlying principles, practical setup steps for common web servers and reverse proxies, comparisons of available approaches (SAN, wildcard, individual certificates), and recommendations for choosing the right solution. Technical details and operational best practices are included so you can confidently design a multi-domain TLS strategy.
How SSL/TLS for multiple domains works: principles and key concepts
TLS certificates bind a cryptographic key to one or more domain names. There are three common certificate strategies for covering multiple names:
- Single-certificate with Subject Alternative Names (SAN): A single certificate contains a list of exact domain names (example.com, www.example.net, api.example.org) in the certificate’s subjectAltName extension. Good when you control a small set of static hostnames.
- Wildcard certificate: A cert for .example.com covers any first-level subdomain (app.example.com, www.example.com) but does not cover example.com unless explicitly included. Useful when you need many subdomains of one base domain.
- Separate certificates per domain: Each domain has its own certificate and private key. This gives the most granularity for key management and delegated issuance.
Server Name Indication (SNI) is a TLS extension that allows a server to present different certificates depending on the hostname requested by the client. Modern browsers and clients support SNI, enabling multiple certificates on a single IP address.
Important technical considerations
- Key type and size: Use ECDSA (P-256/P-384) or RSA 2048+ (RSA-3072/4096 for extra assurance). ECDSA yields smaller keys and faster handshakes; RSA has wider compatibility in legacy clients.
- OCSP stapling: Improves performance and privacy by having the server include the OCSP response during TLS handshake. Enable and monitor stapling freshness.
- Certificate chain: Ensure the full chain (leaf + intermediates) is served. Misconfigured intermediates are a common source of errors.
- Protocol & cipher settings: Prefer TLS 1.3 and a secure TLS 1.2 cipher suite list. Disable SSLv3/TLS 1.0/TLS 1.1.
- Rate limits & automation: Public CAs like Let’s Encrypt enforce issuance rate limits; plan automation and staging properly.
Common application scenarios and recommended approaches
Pick the certificate strategy that matches your deployment:
- Many subdomains under one domain: Wildcard certificate (DNS validation). Simpler to manage, but one key compromise affects all subdomains.
- Multiple independent domains: SAN certificate if the set is small and static; otherwise, separate certificates per domain for better isolation and rotation.
- Multi-tenant hosting or customers-managed domains: Use separate certs per tenant or per customer domain. Automate issuance with ACME and DNS APIs.
- Reverse proxy or load balancer in front of services: Terminate TLS at the proxy using SAN/wildcard or multiple certs with SNI. Optionally, re-encrypt to backends with internal certs.
Practical steps: generating, installing, and automating certificates
Below are concrete technical steps for common setups: nginx, Apache, and a reverse proxy setup. Steps include CSR generation, obtaining certs (Let’s Encrypt examples), configuring the server, and automating renewal.
1) Creating a SAN certificate (manual CSR with OpenSSL)
Use this when your CA requires a CSR with Subject Alternative Names. Create an OpenSSL config file specifying SANs:
1. Create an openssl.cnf snippet that includes SANs in the req_extensions section.
2. Generate a private key and CSR:
- openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out example.key
- openssl req -new -key example.key -out example.csr -config openssl.cnf
3. Submit the CSR to your CA and obtain the certificate and intermediate chain. Ensure you concatenate leaf + intermediate into a fullchain.pem.
2) Obtaining and auto-renewing certificates with Let’s Encrypt (certbot)
Let’s Encrypt is widely used due to free certificates and ACME automation. Two main validation methods exist:
- HTTP-01 challenge: Certbot places a challenge file on your webroot. Works when you can serve HTTP for challenge and ports 80/443 are reachable.
- DNS-01 challenge: Required for wildcard certs. You must add a TXT record to DNS. Use DNS provider API integrations (certbot-dns-plugin or acme.sh with API keys).
Example certbot command for multiple domains (HTTP challenge):
- certbot certonly –standalone -d example.com -d www.example.com -d api.example.org
To expand a certificate to include a new domain:
- certbot certonly –cert-name example.com -d example.com -d new.example.net
For wildcard using DNS challenge:
- certbot -d ‘.example.com’ –manual –preferred-challenges dns certonly
Automate renewals using systemd timers or cron. Always test against the staging endpoint to avoid rate limits:
- certbot renew –dry-run
3) Nginx configuration for multiple certificates (SNI)
For separate certificates, configure server blocks per hostname and point to the respective certs.
Example server block:
- server {
- listen 443 ssl http2;
- server_name example.com;
- ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
- ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
- ssl_protocols TLSv1.2 TLSv1.3;
- ssl_prefer_server_ciphers off; # TLS1.3 uses cipher suites automatically
- # enable OCSP stapling
- ssl_stapling on;
- ssl_stapling_verify on;
- }
Nginx will pick the right certificate based on the SNI hostname. Make sure you have a default server to handle unknown hostnames and to redirect HTTP to HTTPS (port 80).
4) Apache (mod_ssl) multiple vhosts
Apache also supports SNI. Define separate VirtualHost entries:
- <VirtualHost :443>
- ServerName example.com
- SSLEngine on
- SSLCertificateFile /path/to/fullchain.pem
- SSLCertificateKeyFile /path/to/privkey.pem
- </VirtualHost>
Enable the headers and ssl modules (a2enmod) and test config before reloading.
5) Reverse proxies and load balancers (HAProxy, Traefik, Envoy)
Many deployments centralize TLS at an edge proxy. HAProxy can present different certificates per SNI using map files or runtime certificate directories. Traefik and Envoy integrate ACME and can manage certs automatically.
HAProxy example snippet:
- bind :443 ssl crt /etc/haproxy/certs/
- # Put each domain’s PEM file in /etc/haproxy/certs/ named as domain.pem
These proxies also support OCSP stapling and TLS settings; use their recommended secure cipher suites and prefer TLS 1.3.
Operational best practices and hardening
Follow these best practices to keep your multi-domain TLS configuration robust and secure:
- Automate renewals and monitoring: Use ACME clients with hooks to reload services after renewal. Monitor expiry dates and renewal errors.
- Use staging during testing: Avoid hitting public CA rate limits by testing on staging endpoints.
- Least privilege for private keys: Store keys with strict permissions (600) and run services under unprivileged accounts. Consider HSMs or cloud KMS for critical keys.
- Key rotation and revocation planning: Rotate keys periodically and have a documented revocation process.
- Enable OCSP stapling and certificate transparency monitoring: Stapling reduces client OCSP requests; monitor CT logs and revoke if you detect mis-issuance.
- Secure TLS configuration: Disable old protocols, prefer ECDHE for forward secrecy, and enable TLS 1.3 where possible. Use tools like SSL Labs to score and validate.
- Protect DNS: For DNS-01 challenges and wildcard certs, secure your DNS provider account with MFA. Consider DNSSEC if supported by your provider.
- Document and centralize policy: Standardize certificate lifetimes, key types, and renewal windows across teams to avoid configuration drift.
Choosing between SAN, wildcard, and separate certs: pros and cons
Decide based on operational complexity, security boundaries, and scale:
- SAN certs are convenient for a small static list of different domains, reducing the number of certificates to manage. However, adding/removing names often requires re-issuing the cert, and a single compromise affects multiple domains.
- Wildcard certs are excellent for many subdomains under one base domain and simplify issuance. They require DNS validation and pose a bigger blast radius if the private key is compromised.
- Separate certificates offer the best isolation. They are recommended for multi-tenant or high-security environments, albeit with more overhead, which can be mitigated via ACME automation.
Summary and practical next steps
Managing SSL for multiple domains requires a mix of good cryptography choices, automated tooling, and operational discipline. For most site owners and developers, Let’s Encrypt plus certbot (or acme.sh) provides a cost-effective, automatable solution. Use wildcard certs for many subdomains when DNS automation is available, SAN certs for a small set of unrelated hostnames, and separate certificates when you need tenant isolation or specific compliance guarantees.
Operationally, ensure:
- Automation of issuance and renewal with safe testing against staging endpoints.
- Secure storage and permissioning of private keys or use of managed KMS/HSM solutions for critical assets.
- Hardening of TLS parameters, enabling OCSP stapling, and regular scanning (e.g., SSL Labs) to detect regressions.
If you operate VPS instances in the USA or need a reliable hosting environment to centralize certificate management, consider exploring hosting options that make it simple to run ACME tooling and modern proxy stacks. For example, VPS.DO offers flexible virtual servers suitable for deploying reverse proxies and automation tools; more details are available at USA VPS on VPS.DO. Planning the right certificate strategy early reduces outages and improves security posture across all your domains.