openresty / openresty/lua-upstream-nginx-module

cant get upstream.current_upstream_name to work

Open
#39 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
512
Forks
153
Avg merge
1h 29m
Merged PRs (30d)
2

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the current_upstream_name() entry point and the supplied nginx configuration, then reproduce the log_by_lua error with the named upstream and proxy_pass setup. Trace how the module finds the upstream server configuration; done means identifying why no srv conf is found or documenting the required configuration, with the reported upstream name appearing in logs.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua, nginx
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.