Hello everyone, Yellow is in touch, today we will consider the option of working when we havethere is a good domain with history. We will send traffic to subdomains, and in order not to add a new subdomain to DNS records every time and not to fool around with issuing HTTPS certificates for each subdomain, we will create a so-called wildcard certificate for HTTPS, which will allow us to use absolutely ANY subdomains!
What does “absolutely any” mean? Yes, literally any. We take our “trust” domain example.com and come up with subdomains ourselves: lalala.example.com, holyshit.example.com, wow.example.com and so on. All subdomains will automatically display our setup, deployed on the main domain example.com.
In order for this to work, we need 2 things: a wildcard DNS record and a wildcard certificate.ATTENTION: Not all domain registrars support adding wildcard DNS records! Let’s say NameCheap andBegetsupport, but Freenom does not (So if you registered a domain there, then transfer it to other DNS servers, for example to the serversBeget☝ To do this, assign new DNS servers to the domain: ns1.beget.com and ns2.beget.com.
Create a wildcard DNS record
Beget
Everything is simple here: go to«Managing DNS Records»and there we add an entry like this:

- Name: *
- Type: A
- Address: IP address of your server
NameCheap
We go to the domain, then to«Advanced DNS»and let’s go:

- Type: A Record
- Host: *
- Value: Your server IP
We are done with wildcard entries. Let’s go add the certificate!
Create a Wildcard certificate for HTTPS
I’ll show you two options here:
Creating a wildcard certificate inBeget
Let’s go to«Managing Domains and Subdomains»and there we issue a wildcard certificate.ATTENTION: Don’t forget to direct all traffic from subdomains to the main domain!

Creating a wildcard certificate on yourVPS/VDS
I am proceeding from the assumption that you ALREADY INSTALLED Apache or Nginx on your virtual server, a configuration file for your domain has been created, and setup is deployed in the domain folder. You must also have the certbot utility installed to issue certificates. All you have to do is run the following command:
sudo certbot --server https://acme-v02.api.letsencrypt.org/directory -d *.example.org -d example.org --manual --preferred-challenges dns-01 certonly --agree-tos
Replacementexample.orgto your domain, run the command and Certbot itself will add the necessary entries to the web server domain config (in my case nginx) for picking up certificates:

Conclusion
After carrying out all the above manipulations, you will have an unlimited number of subdomains. By the way, if you usemy free clo, then you can assign a separate one for each subdomainwhitefor testing! And that’s all, let’s get a plus and don’t forget to throw indonateto the author for a cup of pu-erh!



Годнота. красава!
вопрос. а можно сертификат выпустить прямо в интерфейсе летсэнкрипт?
я щас делаю через zerossl, заебался раз в полгода обновлять все это дело.
в интерфейсе — хз, разве что в хостинг типа Бегета во встроенном. А на серваках тупо через certbot и cron.
Привет, спасибо за публикацию. А как направить трафик с поддомена на основной домен?
Зависит от хостинга