Need help?

Our experts have had an average response time of 11.7 minutes in August 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Multiple SSL certificates on one IP with Nginx – Set it up now

by | Jan 15, 2021

Would you like to set up multiple SSL certificates on one IP with Nginx? We can help you with it.

Here at Bobcares, we have seen several such Nginx related queries as part of our Server Management Services for web hosts and online service providers.

Today we’ll take a look at how to set up multiple SSL certificates on one IP with Nginx.

 

How we host multiple SSL certificates on one IP with Nginx

SNI ( Server Name Identification) allows hosting multiple SSL certificates on a single IP address.

Traditionally, separate SSL certificates for each site required separate IP addresses. However, this process is now simplified through the use of Server Name Indication (SNI).

Requirements to host multiple SSL certificates on one IP with Nginx

  1. Registered domain names so that it can serve the certificates by SNI.
  2. Nginx must already be installed and running on the VPS.
  3. However, here is the command to install Nginx:
    # sudo apt-get install nginx
  4. SNI must be enabled on the server. Here is the command that displays the version and status.
    # nginx -V

 

Setting up multiple SSL certificates on one IP with Nginx

Now let’s take a look at how our Support Engineers setup multiple SSL certificates.

1. First, we create an SSL certificate Directory.

Here, we are considering two domains example.com and example.org.

The SSL certificate has 2 main parts that is the certificate and the public key. We should create a directory for each virtual hosts SSL certificate.

# mkdir -p /etc/nginx/ssl/example.com
# mkdir -p /etc/nginx/ssl/example.org

2. Next, we create the Server Key and Certificate Signing Request

First, we create an SSL certificate for example.com.

# cd /etc/nginx/ssl/example.com

Then, we create a private server key. While creating, we need to enter a pass-phrase, which is needed later to access the certificate.

# sudo openssl genrsa -des3 -out server.key 1024

Now, we create a certificate signing request by running the below command.

# sudo openssl req -new -key server.key -out server.csr

This will prompt a terminal to display a list of fields that need to be filled in.

3. Remove the Passphrase

We need to remove the passphrase. Even though having the passphrase in place provides better security, the issue appears when one tries to reload the Nginx.

In the event that Nginx crashes or needs to reboot, we will always have to re-enter the passphrase to get the entire web server back online.

# sudo cp server.key server.key.org
# sudo openssl rsa -in server.key.org -out server.key

4. Sign the SSL Certificate

# sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

This certificate will expire after one year.

We have done with the certificate in the first host.

In order to create the certificate in the first host, we switch the directory

# cd /etc/nginx/ssl/example.org

Then we repeat the previous three steps for the second certificate as well. After that, we start adding the certificates to the virtual hosts.

5. Create the Virtual Hosts

After having the certificates saved, we add our information to the virtual host file.

server {
listen 443;
server_name example.com;
root /usr/share/nginx/www;
index index.html index.htm;
ssl on;
ssl_certificate /etc/nginx/ssl/example.com/server.crt;
ssl_certificate_key /etc/nginx/ssl/example.com/server.key;
}

Each file will then contain the virtual host configuration as follows:

server {
listen 443;
server_name example.com;
root /usr/share/nginx/www;
index index.html index.htm;
ssl on;
ssl_certificate /etc/nginx/ssl/example.com/server.crt;
ssl_certificate_key /etc/nginx/ssl/example.com/server.key;
}

Also, we ensure that we have updated server_name, ssl_certificate, and ssl_certificate_key lines to match our details.

Then, we do the same for the second account :

# sudo nano /etc/nginx/sites-available/example.org
server {
listen 443;
server_name example.org;
root {Specify the document root for example.org};
index index.html index.htm;
ssl on;
ssl_certificate /etc/nginx/ssl/example.org/server.crt;
ssl_certificate_key /etc/nginx/ssl/example.org/server.key;
}

6. Activate the Virtual Hosts

Now, we activate the hosts by creating a symbolic link between the sites-available directory and the sites-enabled directory. For that, we run the below commands.

# sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
# sudo ln -s /etc/nginx/sites-available/example.org /etc/nginx/sites-enabled/example.org

7. Restart Nginx

Finally, we restart Nginx by running the below command.

# sudo service nginx restart

[Need any further assistance with Nginx related queries? – We’re available 24*7]

 

Conclusion

Today, we saw how our Support Engineers set up multiple SSL certificates on one IP with Nginx.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF