Multiple domains with SSL on same IP?

Better Stack Team
Updated on November 9, 2023

Yes, you can host multiple domains with SSL on the same IP address using Server Name Indication (SNI). SNI is an extension of the TLS protocol that allows a server to present multiple SSL certificates for different domains on a single IP address.

To set up multiple SSL-enabled domains on the same IP using SNI, you'll generally follow these steps:

  1. Generate SSL certificates for each domain: Create SSL certificates for each domain you want to host. You can either obtain separate certificates from a Certificate Authority (CA) or generate self-signed certificates using OpenSSL.
  2. Configure your web server: Configure your web server to use SNI and associate each SSL certificate with its respective domain.

    For example, with Apache or Nginx, you would set up your virtual hosts to specify the SSL certificate and the domain it should serve. Here's a simplified example for Apache:

     
    <VirtualHost *:443>
        ServerName www.example1.com
        ServerAlias example1.com
        SSLEngine on
        SSLCertificateFile /path/to/certificate1.crt
        SSLCertificateKeyFile /path/to/privatekey1.key
        # Other SSL configurations
        # ...
    </VirtualHost>
    
    <VirtualHost *:443>
        ServerName www.example2.com
        ServerAlias example2.com
        SSLEngine on
        SSLCertificateFile /path/to/certificate2.crt
        SSLCertificateKeyFile /path/to/privatekey2.key
        # Other SSL configurations
        # ...
    </VirtualHost>
    
    

    This way, the server can differentiate which certificate to provide based on the requested domain.

  3. Enable SNI support: Ensure that your server and SSL library support SNI. Most modern servers (Apache, Nginx, IIS) and SSL libraries (OpenSSL, etc.) support SNI.

  4. Testing: Test the configuration by accessing each domain in a browser that supports SNI. Most modern browsers support SNI, but some older versions or certain platforms might have issues.

While SNI allows multiple SSL certificates on a single IP, it's important to note that older browsers or systems that don't support SNI might encounter difficulties accessing the hosted domains. Always consider the compatibility requirements of your target audience when using SNI for hosting multiple SSL-enabled domains on the same IP address.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github