W
W
wartur2012-11-16 15:55:37
Nginx
wartur, 2012-11-16 15:55:37

How to block access to other domains in nginx, except for the specified ones

Hello.

There is a system familiar to everyone
nginx - apache - mod_php - mysql

In nginx, the domains to which they are proxied to the backend are indicated. Everything works, only if you specify an address that is not known to nginx, then for some reason it will proxy such a request to the backend. I would like to get rid of this. I tried to set the default one but without success somehow.

Actually this was the question.
Here is actually an example of access that needs to be denied (apache page) 188.134.79.140/ well, of course, for any requests like example.com to my server, it must also respond with a 3-letter message, and not a backend transmission, and it already sends. It turns out the problem is, I need to somehow specify a rule that does not allow anyone other than the specified addresses, for example, herewartur.ru/

ZY: on Apaches it becomes by means of a virtual host by default. For some reason, my ngins does not pick up, or am I doing something wrong?

Thank you for your attention.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
W
wartur, 2012-11-16
@wartur

listen 80 default_server;
Thank you all =). Good luck.

V
Vlad Zhivotnev, 2012-11-16
@inkvizitor68sl

server {
listen 80 default;
return 403;
or return 444;
}

A
allnightlong, 2012-11-16
@allnightlong

If I understand correctly, then you need something like this:
server {
server_name _;
return 444;
}

J
JustLuckyGuy, 2012-11-16
@JustLuckyGuy

by default, the first specified server is default, i.e. all unknown requests go to it, unless another one is specified with the default_server directive

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question