How does nginx, know which domain name or ip? is used to access the local machine for each visit request?

for example, this request is accessed directly through ip? Or is it accessed through a domain name?

Mar.20,2021

there are several ways to do this. You can log different visits to different log files and distinguish ip and domain name access from virtual hosts.

in addition, you can customize the contents of the log file, record the $http_host , and use the log_format configuration instruction to customize the log format

.

log_format host
this is the host requested by the user


judge

by the Host attribute in request headers

Menu