G
G
glukkkk2014-05-23 11:53:44
Nginx
glukkkk, 2014-05-23 11:53:44

How to block access to the site by domain through the nginx config

At the moment, the site opens both at the domain.com domain and at the IP address 10.11.12.13. I need, using the nginx config, to close access to the site by domain so that it is available only at the IP address 10.11.12.13 and is not available at domain.com.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor, 2014-05-23
@glukkkk

If there are no more sites (virtual hosts) on the server, then the following is needed: add server_name
with your ip to the already existing virtual host config in the server section, and if there is server_name domain.com, remove it:

server {
    server_name 10.11.12.13;
...
}

Next, we make another virtual host for our domain name or for the default host, where all requests that do not fall into our virtual host will go and make a ban for everyone in it:
server {
    listen 80;
    server_name domain.com;
    deny all;
}

Here, instead of server_name domain.com , you can write server_name _ for the default host.
Documentation:
nginx.org/ru/docs/http/ngx_http_core_module.html#s...
nginx.org/ru/docs/http/ngx_http_access_module.html

G
glukkkk, 2014-05-23
@glukkkk

Thank you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question