Bobcares

Nginx multiple domains SSL – Common errors and fixes

by | Jan 29, 2021

Nginx multiple domains SSL is a digital security certificate that allows multiple hostnames protected by a single certificate.

However, improper redirection settings, misconfiguration of the Nginx file, and wrong SSL port entry in the configuration file cause problems.

As part of our Server Management Services, we often get requests from our customers to resolve problems with Nginx multiple domains SSL.

Today, let us focus on the top 3 common issues it causes and how our Support Engineers fix them.

 

SAN certificate & it’s salient features

Nginx multiple domains SSL is also known as SAN (Subject Alternative Names) certificate.

The SAN certificate secures multiple fully qualified domain names with a single certificate. It is well known as a Unified Communication Certificate (UCC) or an Exchange certificate.

A single SAN certificate allows protecting multiple subdomains like www.domain.com, example.domain.com, www.domain.net.

Some of the important features include,

  • Can secure up to 2000 entries.
  • Can use on unlimited multiple servers concurrently.
  • It can reissue to change domains at any time without extra fees or costs.

 

Nginx multiple domains SSL – Common errors and fixes

From our experience in managing servers, we’ve come across customers who report us with errors in Nginx multiple domains SSL.

Let’s take a closer look at 3 of the common errors it causes and how our Support Engineers figure them out.

 

  • Improper redirection setting

Recently we had a customer reporting that once he set the redirection of the subdomains (domain2.com,domain3.com) to the main domain (domain1.com), he couldn’t access the main domain with HTTPS.

For redirection to work properly we need to configure it correctly. So, to solve this problem we took the following steps.

Initially, we open the Nginx configuration file /etc/nginx/nginx.conf.

Then we create https server blocks for every subdomain.

In order to do that, we add the following code in the configuration file:

server {
listen *:443 ssl;
server_name domain1.com;
ssl_certificate /path/to/domain1.crt; 
ssl_certificate_key /path/to/domain1.key;
return 301 https://www.domain1.com$request_uri;
}
server {
listen *:443 ssl;
server_name domain2.com www.domain2.com;
ssl_certificate /path/to/domain2.crt; 
ssl_certificate_key /path/to/domain2.key;
return 301 https://www.domain1.com$request_uri;
}

In addition, we verify the syntax by running the command:

nginx -t

Finally, we restart the service to reflect the changes made in the configuration file.

service nginx restart

This fixed the problem and the user could redirect the subdomain to the main domain which worked properly.

 

  • Misconfiguration of Nginx file

Similarly, another customer reported us with another issue. When he tries to access the subdomain (domain2.com), it results in the error, “502 bad gateway, Welcome to Nginx, further configuration is required, too many redirects”

Our Support Engineers executed the following steps to fix the error.

Initially, we open the /etc/nginx/nginx.conf file.

After checking the configuration file we found that because of the proxy, the subdomain redirects HTTP instead of HTTPS.

So, we removed all the proxy line from the subdomain’s configuration file.

Similarly, the parameter return and try_files cannot take place together with the current set up on port 80 as shown below.

server {
    listen 80;
    server_name domain2.com www.domain2.com;
    return 301 https://$server_name$request_uri;
    location / {
         try_files $uri $uri/ =404;
    }

So we remove it and finally, the subdomain configuration setting will look like:

server {
listen 80;
server_name domain2.com www.domain2.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name domain2.com www.domain2.com;
root /home/Bas/domain2;
index index.html index.htm;
ssl_certificate /etc/letsencrypt/live/domain2.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain2.com/privkey.pem;
include /etc/nginx/snippets/ssl-params.conf;
location / {
try_files $uri $uri/ =404;
}
}

This solved the error and the user could access the subdomain without any error.

 

  • Wrong entry of SSL port

Occasionally, a wrong entry or incorrect SSL port added in the configuration file causes trouble in accessing the domain.

One of our customers reported that when he tries to access the domain with HTTPS it shows the wrong content or page.

Our first step was to check the Nginx configuration file.

By analyzing, we found that in the Nginx configuration file, /etc/nginx/nginx.conf the entry for SSL port was mistyped as “433”. Hence, it always results in the wrong page.

SSL uses port 443 to listen. By giving the right value for port SSL we were able to resolve this issue.

server {
    listen 80;
    listen 443 ssl;
    server_name example.com;
}

Once we edit, we restart the service.

[Having trouble with Nginx multiple domains SSL? We’ll fix it for you.]

 

Conclusion

To sum up, the multi-domain SSL certificate offers security for multiple websites. Today, we saw the top 3 common issues with “Nginx multiple domains SSL” and how our Support Engineers fixed them.

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 *

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

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
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

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

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

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