T
T
Twelfth Doctor2017-10-01 15:17:44
Nginx
Twelfth Doctor, 2017-10-01 15:17:44

How to bind an IP address to a domain?

Hello. Bought a dedicated IP address for my domain. There is a small VPS that runs Nginx (proxy) + Apache. Now there is a task to bind this IP address to the domain.
Do I understand the sequence of actions correctly:
1) A-records pointing to the IP address of the VPS are deleted in the DNS zone of the domain
2) A-records are added to the DNS zone pointing to the purchased IP address
3) Listen 1.2.3.4:80 is written in the Nginx configuration ;
4) Restart Bind, Nginx, Apache
(Apache listens on 127.0.0.1:81)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Verbin, 2017-10-01
@verdex

Oh, and they advised you, the domain is in listen ...
It should be like this (conditionally you have ip = 1.1.1.1)

listen	1.1.1.1:80;
server_name domain.com www.domain.com;

Or, without binding to the ip address
It should be like this (conditionally you have ip=1.1.1.1)
listen	80;
server_name domain.com www.domain.com;

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

A small note. When you navigate to a domain name in a browser, your browser makes a DNS request to the NS server of the domain, asks for the IP address from the A record of the specified domain, then accesses this IP address on port 80 and asks the server to give it the content of domain.com, if any available in the configuration. If the domain is still configured, the web server returns the contents of the document_root or what is configured, if not, it returns the contents of the first configured host in the config chain to the client (it is usually configured without domains, an empty index.html is put in the document_root).
Remark 2. And given that you have apache running for nginx, you need to remember to tell nginx where to give content for this domain.
In your case, "location /" should be something like this.
location / {
        proxy_pass	http://127.0.0.1:81;
}

D
Dimonchik, 2017-10-01
@dimonchik2013

IP must be assigned to the controlled network interface to which nginx is docked and all that,
then change the A record (or add it, it will open two by two)

M
mafusailmagoga, 2017-10-01
@mafusailmagoga

The Nginx configuration specifies listen 1.2.3.4:80;

This means that nginx will accept requests for ANY DOMAIN at this address.
If you need only for this domain, then instead of IP, you need to specify the domain name in listen. Letters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question