You need to go into your DNS configuration (cloudflare, register.br, godaddy, dynadot) and add an alias to your subdomain within the DNS configuration of the existing domain.
In addition, within the vhost configuration of your existing web server (apache, nginx lighttpd and so on), there should be an entry pointed to root for the subdomain folder, this is usually created by cpanel among other managers automatically. / p>
This is a classic example of nginx vhost listening on port 80 which is the browser's. Note that the root folder of the domain is / var / www / html and that this template will be executed when there is a request that meets the defined server_names, in this case www.mydomain.com and mydomain.com . So there should also be the same vhost structure on your server for your new subdomain (subdomain.mydomain.com) pointing to your root folder. Despite the different syntax the procedure is the same for apache and so on.
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name www.meudominio.com meudominio.com;
location / {
try_files $uri $uri/ =404;
}
}
For example, let's say that your domain is mydomain.com and you want to open the subdomain.mydomain.com
Within the DNS settings you will see entries with these:
A meudominio.com 158.69.20.14
A www 158.69.20.14
In other words, www is a subdomain of mydomain.com and points to the ip of your server, in this case if we want to add a new subdomain, just add a new alias in your DNS, like this:
A meudominio.com 158.69.20.14
A www 158.69.20.14
A subdominio 158.69.20.14
Saying that there is an alias (A) subdomain, which points to the ip of this machine too or even use another server with a different ip. When someone makes a request for subdomain.mydomain.com, the DNS resolver will forward the request to the ip pointed in its DNS record, arriving at the destination server, the web server finds the vhost template with the requested server_name and answers the request pointing to the internal folder defined in root of your vhost file. Generally adding subdomains to your DNS does not require timeout since the primary domain has already been propagated over the network.