Y
Y
Yan Vetrov2019-05-25 23:07:31
Nginx
Yan Vetrov, 2019-05-25 23:07:31

The site is accessible by IP NGINX. How to fix?

It turns out that I am a front-end developer, I understand the backend very poorly, but there is a task that I cannot find a solution to. If a site hosted on VDS, managed by BitrixVM and, as I understand it, using NGINX. Virtual server on CentOS 7. The problem is that it is possible to access the site by IP address, how can I disable IP access and redirect to the domain?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MegaLoadOn, 2019-05-26
@id_pripyat

Blocking by ip:
server {
listen 80;
server_name "";
return 444;
}
If you need to redirect to a domain then:
server {
listen 80;
server_name "";
return 301 https://domain.local$request_uri;
}

K
ky0, 2019-05-25
@ky0

Add a server with the appropriate server_name or make it default with the behavior you want. HTTPS in this way, by the way, will not be able to redirect due to a certificate error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question