Size: a a a

2021 April 07

AN

Anton Noginov in nginx_ru
Йеп
источник

HF

Hugo Florentino in nginx_ru
OK then, but the doubt remains:
Why is the request not being captured by the default virtualhost ?
источник

E

Ernesto 🇨🇺 in nginx_ru
Is captured by the default virtualhost but your location internal for errors don't have a file log defined so they use the default log
источник

HF

Hugo Florentino in nginx_ru
it does
источник

AN

Anton Noginov in nginx_ru
It's being captured there. But as
Requests are logged in the context of a location where processing ends. It may be different from the original location, if an internal redirect happens during request processing. 
- the log phase occured around /404.html, which has no access log defined - therefor default one was used.
источник

E

Ernesto 🇨🇺 in nginx_ru
Exactly
источник

HF

Hugo Florentino in nginx_ru
not quite,

location / {
 access_log /var/log/nginx/catchall.log;
 return 404;
}
источник

HF

Hugo Florentino in nginx_ru
and I do have a 404.html
источник

E

Ernesto 🇨🇺 in nginx_ru
Not, the location for the 404
источник

E

Ernesto 🇨🇺 in nginx_ru
location ~ '^/(400|401|403|404|405|429|502|503)\.html$' {
 root /var/www/error;
 internal;
}


this one don't have a log file so they use the default log
источник

E

Ernesto 🇨🇺 in nginx_ru
when you return 404 is captured by this other location
источник

HF

Hugo Florentino in nginx_ru
OK, we are talking about separate things here
источник

HF

Hugo Florentino in nginx_ru
I am not interested in capturing the redirect, I want to capture what arrives to the root location, before it's redirected to the 404
источник

E

Ernesto 🇨🇺 in nginx_ru
but the logs is registered by the latest location in this case that block
источник

HF

Hugo Florentino in nginx_ru
really ?
источник

AN

Anton Noginov in nginx_ru
Then you should disable error interceptions there. That's the way how it works.
источник

HF

Hugo Florentino in nginx_ru
how should I do that ?
источник

AN

Anton Noginov in nginx_ru
Disable error_pages for default_server.
Or, define a log file in default_server context, not a location; as a request ends in other location than /
источник

E

Ernesto 🇨🇺 in nginx_ru
exactly the request ends in the location with the errors
источник

HF

Hugo Florentino in nginx_ru
I had placed access_log within location because I wanted to exclude things like favicon.ico, robots.txt and so on
источник