Skip to content

cant get upstream.current_upstream_name to work #39

@amgorb

Description

@amgorb

tried different variants of configuration, no change
config:
$upstream_name used in log_format

server {
.. 
set $upstream_name 'undef';
..
.. 
}
location @siteapi_common {
 ..
  log_by_lua_block {
  ngx.var.upstream_name = "test"
  local upstream = require "ngx.upstream"
  ngx.log(ngx.INFO, "upstream = " .. tostring(upstream.current_upstream_name()))
  local upstream_name = upstream.current_upstream_name()
  ngx.var.upstream_name = upstream_name
  }
..
    proxy_pass $backend_scheme://_bk_api_common;
}

expect to see upstream name (_bk_api_common) in logs but got 'test' string and following in error.log:

2016/12/29 16:13:16 [error] 12547#12547: *20 failed to run log_by_lua*: log_by_lua(api_fallback:36):4: no srv conf for upstream
stack traceback:
        [C]: in function 'current_upstream_name'
        log_by_lua(api_fallback:36):4: in function <log_by_lua(api_fallback:36):1> while logging request, client: ip, server:test, request: "GET /_api/deals/", host: "dev-10--www.testsite"

upstreams are working fine.
What can cause 'no srv conf for upstream' error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions