Size: a a a

2021 April 07

HF

Hugo Florentino in nginx_ru
If I place the access_log at the server block, then even though I declare such location blocks with access_log off and log_not_found off it logs them anyway
источник

HF

Hugo Florentino in nginx_ru
So the problem is error_pages then when used in a default server block?
The documentation doesn't mention this anywhere
источник

AN

Anton Noginov in nginx_ru
The documentation states that definitely: http://nginx.org/en/docs/http/ngx_http_log_module.html
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. 


If you  want to skip stuff like robots.txt - just define a separate location for them.
But that's weird - you want to log all the requests to unknown host, and http://ip/robots.txt kinda one of.
источник

HF

Hugo Florentino in nginx_ru
So nginx doesn't have a way then to catch requests as they are before redirecting to custom error pages ?
источник

HF

Hugo Florentino in nginx_ru
The directive access_log then is a bit crippled
источник

AN

Anton Noginov in nginx_ru
That makes no sense indeed. As prior to internal redirect you don't have let's say status code defined - it might be amended withing further processing.
As well as response itself.
источник

AN

Anton Noginov in nginx_ru
You may however do a wrapper there - either logging with lua, or using let's say auth_request to log

Number of ways.
источник

HF

Hugo Florentino in nginx_ru
If you have a reverse proxy, you might want to capture all requests exactly as they come for auditing purposes. The destination is irrelevant in that scenario.
источник

LS

Lilo Stich in nginx_ru
Что тут происходит? Можно вклинуться?

Hi, guys.

I have 2 Nginxs here.
One is Stream on 443 with proxy_protocol enabled.
And second is HTTP with SSL termination.
Whole day tried to log the IP of clients, bliad.

Is this the correct way to log it?

http_x_forwarded_for="$proxy_protocol_addr"


It gaves me my local IP address. Im connect over VPN.
источник

AN

Anton Noginov in nginx_ru
In that case that's ridiculous to intercept errors there. that's dumb indeed.
источник

HF

Hugo Florentino in nginx_ru
OK, I guess I am that dumb, LOL
источник

HF

Hugo Florentino in nginx_ru
the problem again is that lua doesn't log anything because of the redirect
источник

AN

Anton Noginov in nginx_ru
В прокси протоколе же отдается remote_addr
источник

AN

Anton Noginov in nginx_ru
Use other hook.
Mine logs fine whole session :)
источник

HF

Hugo Florentino in nginx_ru
notice the problem is only when placing the access_log witin the location block
источник

LS

Lilo Stich in nginx_ru
Дело в том, что грёбаный 2ой Nginx поднят внутри куб кластера, и если я использую $remote_addr - то получаю какой-то IP из кубовых ендпойнтов - 10.233.76.128.
источник

LS

Lilo Stich in nginx_ru
Видимо IP сервиса кубового, или эндпойнтов
источник

LS

Lilo Stich in nginx_ru
Первый L3 (stream) балансер балансит по NodePort-ам куба.
источник

AN

Anton Noginov in nginx_ru
Ахахаха

Добро пожаловать в волшебный мир cloud native networking.
источник

LS

Lilo Stich in nginx_ru
🥺
источник