Configure Nginx for WildCard SSL (manual setups)
In order to create WildCard domain for global access, we need to create WildCard DNS entry (A entry) for the subdomains on our DNS server.
IE: *.example.com for our base domain entry (example.com).
This way, all incoming traffic will be recognized and will be routed in the proper domain.
Step 1:
You will need to configure the Nginx config file /etc/nginx/sites-available/default. In most cases (new installations), this configuration file, includes the following contents:
server {
listen 80 default_server;
listen [::]:80 default_server;
...
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
...
}
You will need to edit these contents and replace them according to your domain’s preferences.
In the example below, we will use themesic.com domain for our Perfex SaaS module WildCard Installation:
server {
listen 80 default_server;
listen [::]:80 default_server;
...
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name themesic.com *.themesic.com;
...
}
Step 2:
After making the proper changes, you will need to contact to the host provider, in order to add the WildCard DNS entry in your DNS zone.
If you handle the DNS zone on your own, you can do that manually. Here’s an example of adding a WildCard DNS entry in CloudFlare: https://developers.cloudflare.com/dns/manage-dns-records/reference/wildcard-dns-records/