How to bind IP address to the domain?

Hello. I bought a dedicated IP address for your domain. There is a small VPS which revolves Nginx (proxy) + Apache. Now came the task to bind the IPS to the domain.
Whether correctly I understand sequence of actions:
1)In the DNS zone of the domain, deleted the A-record pointing to IP address of the VPS
2)In the DNS zone added the A-record that points to the purchased IP address
3)In your Nginx configuration registers listen 1.2.3.4:80;
4)Restart Bind, Nginx, Apache
(Apache is listening to 127.0.0.1:81)
June 14th 19 at 21:04
3 answers
June 14th 19 at 21:06
Solution
Oh, and I have advised you domain to listen...

It must be so (relatively ip=1.1.1.1)
listen 1.1.1.1:80;
server_name domain.com www.domain.com;


Or, without binding to ip address
It must be so (relatively ip=1.1.1.1)
listen 80;
server_name domain.com www.domain.com;

Also, there may be several ports, such as for ssl.
listen 80;
listen 443 ssl;
server_name domain.com www.domain.com;

A small remark. When you go to a domain name in a browser, your browser makes a DNS request to the NS server in the domain that asks the IP address of A record in the specified domain, then is drawn to this IP address on port 80 and requests the server to give it content domain.com if there is one in the configuration. If the domain is still configured - the web server returns the contents of the document_root or what you configured - if not, gives the client the contents of the first host configured in the chain configuration (usually configure without a domain, document_root put in empty index.html).

Ремарка2. And considering the fact that you have nginx running behind apache, you should not forget to tell nginx where to send content for this domain.
In your case, in "location /" should be something like that.
location / {
 proxy_pass http://127.0.0.1:81;
}
But if I have an alias of this site - for example, alias.com and I want him either to use a separate IP address, then I need to add some blocks server { with the same content but different server_name ?
Or this:
listen 1.1.1.1:80;
listen 2.2.2.2:80;
server_name domain.com www.domain.com alias.net www.alias.net;

Have alias.net the A record and specify the IP address 2.2.2.2 - Glennie_Beie commented on June 14th 19 at 21:09
So you have 2 different domain must refer to the same site on different IP addresses?
Then 2 of the unit server in each IP. In each domain a record with the corresponding IP.

2 if domain should refer to the same site on the same IP one unit with one IP, with a bunch of domains in server_name.
Remember, you are not ip connected to domain and domain to IP-to-have, though it's very simple said. - Aylin_Hetting commented on June 14th 19 at 21:12
June 14th 19 at 21:08
IP must designate a controlled network interface, which docked with nginx and everything

then to change the a record ( or add, will be for two to open)
June 14th 19 at 21:10
In your Nginx configuration registers listen 1.2.3.4:80;


This means that nginx will be at this address to accept requests FOR ANY DOMAIN.
If you only need for this domain - that is the IP you need to enter in listen is the domain name. Letters.
And if I specify to listen domain.com inquiries from www.domain.com he would not accept? In this case, I have to write something like this:
server {
listen domain.com;
listen www.domain.com;

Also where do I put the IP address? I need to IP have specified only 1 specific domain. - Glennie_Beie commented on June 14th 19 at 21:13

Find more questions by tags NginxHosting