T
T
tgarl2022-03-15 11:06:54
linux
tgarl, 2022-03-15 11:06:54

How to find out by domain name or by ip a request came and for which one specifically?

Good afternoon.
How can you determine the full path of a request?
those. we have one site responsible for IP and for all non-existent subdomains. Accordingly, in the logs of this particular site, I see queries like "/blah-blah-blah/". But I would like to understand the request was on 1.1.1.1/bla-bla-bla/ or site.ru/bla-bla-bla/ or sub.site.ru/bla-bla-bla/
This implies 2 questions:
1. how to determine and log this moment
2. if we have different ip:port services, is it possible to somehow configure it to a non-existing subdomain or only by ip the response is 404 or 503

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2022-03-15
@tgarl

There is a very simple advice for both of your questions - make virtual hosts, for a site by name, for a site by ip, etc. In virtual hosts, describe the desired behavior of the web server and your logs for each. That is, if the client came to 192.168.1.1 - always get 404 , and if on site.ru - a normal site, etc.
How to do it depends on your web server - both apache and nginx make it easy, it's in all the examples and documentation.

K
ky0, 2022-03-15
@ky0

Requests always come to an IP address. The difference is in the header Host, which can be logged at the web server level.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question