C
C
ceasefire2017-05-29 14:04:44
PHP
ceasefire, 2017-05-29 14:04:44

How to implement domain parking?

It is necessary to implement the domain parking functionality.
The implementation written below is based on assumptions, so if there are any other options, please describe them.
First, the CNAME of the domain is tied to a specific site (park.example.ru), on which the script runs, which determines where the user wanted to go, and the necessary page is already substituted there.
I don’t understand how to bind CNAME to my server, as I understand it, I can use the server management system like VestaCP, where I will bind all CNAMEs to myself, do I understand correctly?
Then you need to write a script (in PHP) that will load the page (I don’t understand how it will work yet). Tell me in which direction to dig and how to implement it in the best way.
Thank you very much.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2017-05-29
@shambler81

chame is an alias in essence
. And you need to specify a record like " А" at the beginning.
Here it just answers which IP will be given by this domain.
In your case, Vesta has a built-in DNS server, and for sites that will be hosted on it, it will be enough to specify the NS server of your server,
for example, such as
NS1.YOUR_SERVER.RU
Well, of course, the DNS record of the server itself will not work. agree it's stupid.
So the domain of the server itself needs to be delegated to a third-party service and returned from it already A record
Therefore, how to do it
1. Does your registrar have a free one. or paid domain parking with editing DNS zones. (reg.ru) for free.
2. If not, then delegate the domain to Yandex https://pdd.yandex.ru/
do not be embarrassed that this is about mail, there is a full-fledged DNS zone editor, and mail is already there by choice, I would recommend leaving it on Yandex.
but here you can see.
3. Create entries like
your site.ru - A 1.1.1.1
www. - A 1.1.1.1
NS1 - A 1.1.1.1
NS2 - A 2.2.2.2 (if there is no second IP, then the first one can be, but there may be problems with parking com sites)
And so on.
Accordingly, it will continue like this:
The client prescribes the NS of the server ns1.your_sayt.ru
He gives the A record of the domain where the DNS server is located, which will give the A record from his domain.
php is not needed here
If you are wondering what happens next
HE will get the IP of the site, most likely it will be the same IP as one of the ns servers, if you have not bought additional ones.
the magic is that Apache can breed sites itself depending on the HTTP header when requesting, and substitute the folder you need.
In fact, hundreds of sites can live on 1 IP and the same port, this is not a limitation for a web server

L
lehha, 2017-05-29
@lehha

You do not need to bind all CNAMEs to yourself, it is enough to hang one site per IP and any sites with this IP will open the main site as an alias. Just check nginx/apache so that it is not bound by server_name
And then there are two ways to bind domains to IP:
1. so that the owner himself registers CNAME / A on his domains;
2. so that it simply delegates the domain to your DNS servers, and they will already give the necessary CNAME / A records.
Any script on your server side will determine by the HTTP HOST header what kind of domain it is and what to show it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question