Можно через lua например
nginx.ingress.kubernetes.io/configuration-snippet: |
if ($http_x_correlation_id = "") {
set_by_lua $request_uuid '
if ngx.var.http_x_correlation_id == nil then
local f = assert(
io.open("/proc/sys/kernel/random/uuid", "rb"))
local uid = assert(f:read())
f:close()
return uid
else
return ngx.var.http_x_correlation_id
end
';
more_set_headers "X-Correlation-Id: $request_uuid";
set $http_x_correlation_id $request_uuid;
}
proxy_set_header X-Correlation-Id $http_x_correlation_id;