{"id":1056,"date":"2022-08-18T04:33:00","date_gmt":"2022-08-18T10:33:00","guid":{"rendered":"http:\/\/blog.supportpro.com\/?p=1056"},"modified":"2026-03-31T00:03:53","modified_gmt":"2026-03-31T06:03:53","slug":"multiple-ssl-certificates-on-a-single-ip-using-nginx","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/multiple-ssl-certificates-on-a-single-ip-using-nginx\/","title":{"rendered":"Multiple SSL Certificates on a Single IP Using Nginx"},"content":{"rendered":"\n<p>SNI ( Server Name Identification) allows you to host multiple SSL certificates on a single IP address. Although, hosting several sites on a single virtual private server is possible with the use of virtual hosts, providing separate SSL certificates for each site traditionally required separate IP addresses. The process has now been simplified through the use of Server Name Indication (SNI), which sends a site visitor the certificate that matches the requested server name.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Requirements to setup Multiple SSL <\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Domain names should be registered in order to serve the certificates by SNI.<\/li>\n\n\n\n<li>Root Privileges to the server.<\/li>\n\n\n\n<li>Nginx should already be installed and running on your VPS<\/li>\n<\/ol>\n\n\n\n<p><strong>To install Nginx:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># sudo apt-get install nginx<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<p><strong>Make sure that SNI is enabled in the server<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># nginx -V ; which displays the version and the status.<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Set up Process<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Create the SSL certificate Directory<\/h3>\n\n\n\n<p>For easy understanding, I will be working to create a server that hosts both example.com and example.org.<\/p>\n\n\n\n<p>The SSL certificate has 2 parts main parts: the certificate itself and the public key. We should create a directory for each virtual hosts SSL certificate.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># mkdir -p \/etc\/nginx\/ssl\/example.com\n# mkdir -p \/etc\/nginx\/ssl\/example.org<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">2. Create the Server Key and Certificate Signing Request<\/h3>\n\n\n\n<p>First, we create SSL certificate for example.com<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># cd \/etc\/nginx\/ssl\/example.com<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<p>Now, create the private server key. You will be asked to enter a pass-phrase, which is needed later to access the certificate.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># sudo openssl genrsa -des3 -out server.key 1024<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<p>Create certificate signing request :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># sudo openssl req -new -key server.key -out server.csr<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<p>This will prompt terminal to display a lists of fields that need to be filled in.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Remove the Passphrase<\/h3>\n\n\n\n<p>We need to remove the passphrase. Although having the passphrase in place does provide heightened security, the issue starts when one tries to reload nginx. In the event that nginx crashes or needs to reboot, you will always have to re-enter your passphrase to get your entire web server back online.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># sudo cp server.key server.key.org\n# sudo openssl rsa -in server.key.org -out server.key<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">4. Sign your SSL Certificate<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<p>This certificate will expire after one year.<\/p>\n\n\n\n<p>We have done with the certificate in the first host.<\/p>\n\n\n\n<p>To create the certificate in the first host : switch the directory<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># cd \/etc\/nginx\/ssl\/example.org<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<p>Repeat the previous three steps for the second certificate. Once it is finished, we can start adding the certificates to your virtual hosts.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Create the Virtual Hosts<\/h3>\n\n\n\n<p>Once we have the certificates saved, we can add in our information in the virtual host file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\nlisten 443;\n\nserver_name example.com;\n\nroot \/usr\/share\/nginx\/www;\n\nindex index.html index.htm;\n\nssl on;\n\nssl_certificate \/etc\/nginx\/ssl\/example.com\/server.crt;\n\nssl_certificate_key \/etc\/nginx\/ssl\/example.com\/server.key;\n\n}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<p>Each file will then contain the virtual host configuration as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\nlisten 443;\n\nserver_name example.com;\n\nroot \/usr\/share\/nginx\/www;\n\nindex index.html index.htm;\n\nssl on;\n\nssl_certificate \/etc\/nginx\/ssl\/example.com\/server.crt;\n\nssl_certificate_key \/etc\/nginx\/ssl\/example.com\/server.key;\n\n}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<p>Make sure that you have updated server_name, ssl_certificate, and ssl_certificate_key lines to match your details.<\/p>\n\n\n\n<p>Do the same for the second account :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># sudo nano \/etc\/nginx\/sites-available\/example.org<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\nlisten 443;\n\nserver_name example.org;\n\nroot {Specify the document root for example.org};\n\nindex index.html index.htm;\n\nssl on;\n\nssl_certificate \/etc\/nginx\/ssl\/example.org\/server.crt;\n\nssl_certificate_key \/etc\/nginx\/ssl\/example.org\/server.key;\n\n}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">6. Activate the Virtual Hosts<\/h3>\n\n\n\n<p>Now, activate the hosts by creating a symbolic link between the sites-available directory and the sites-enabled directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># sudo ln -s \/etc\/nginx\/sites-available\/example.com \/etc\/nginx\/sites-enabled\/example.com\n# sudo ln -s \/etc\/nginx\/sites-available\/example.org \/etc\/nginx\/sites-enabled\/example.org<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">7. Restart nginx<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># sudo service nginx restart<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<p>You should now be able to access both sites, each with its own domain name and SSL certificate.<\/p>\n\n\n\n<p>If you require help, <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">contact SupportPRO Server Admin<\/a><\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center has-white-background-color has-background\"><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\">Facing issues? <\/p>\n\n\n\n<p class=\"has-large-font-size\">Our technical support<br>engineers can solve it. <\/p>\n\n\n\n<!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper\" id=\"hs-cta-wrapper-3350a795-db50-482f-9911-301930d1b1be\"><span class=\"hs-cta-node hs-cta-3350a795-db50-482f-9911-301930d1b1be\" id=\"hs-cta-3350a795-db50-482f-9911-301930d1b1be\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/3350a795-db50-482f-9911-301930d1b1be\" ><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-3350a795-db50-482f-9911-301930d1b1be\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/3350a795-db50-482f-9911-301930d1b1be.png\"  alt=\"Contact Us today!\"\/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '3350a795-db50-482f-9911-301930d1b1be', {\"useNewLoader\":\"true\",\"region\":\"na1\"}); <\/script><\/span><!-- end HubSpot Call-to-Action Code -->\n<\/div><figure class=\"wp-block-media-text__media\"><img fetchpriority=\"high\" decoding=\"async\" width=\"904\" height=\"931\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png\" alt=\"guy server checkup\" class=\"wp-image-12943 size-full\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png 904w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-291x300.png 291w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-768x791.png 768w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-585x602.png 585w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>SNI ( Server Name Identification) allows you to host multiple SSL certificates on a single IP address. Although, hosting several sites on a single virtual private server is possible with&hellip;<\/p>\n","protected":false},"author":5,"featured_media":12912,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1],"tags":[53,106],"class_list":["post-1056","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-miscellaneous","tag-cloud","tag-server"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1056","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=1056"}],"version-history":[{"count":8,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1056\/revisions"}],"predecessor-version":[{"id":16855,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1056\/revisions\/16855"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media\/12912"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=1056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=1056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=1056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}