zlhgo edited a comment on issue #5596:
URL: https://github.com/apache/apisix/issues/5596#issuecomment-987792571
i have written a plugin for this issue, but there is a problem that the `set
$upstream_name -;` directive must place in the location section, so maybe we
are missing a http_server_location_configuration_snippet item.
1. nginx config
```
log_format main escape=default '$remote_addr - [$remote_addr] - $remote_user
[$time_local] "$request" $status $body_bytes_sent "$http_referer"
"$http_user_agent" $request_length $request_time [$upstream_name]
$upstream_addr $upstream_response_length $upstream_response_time
$upstream_status $req_id $host [$scheme]';
location / {
set $upstream_name -;
}
```
2. code
```
function _M.before_proxy(conf, ctx)
-- maybe the ctx.matched_upstream can not access in the access phase
ngx.var.upstream_name = ctx.matched_upstream.name
core.log.warn("set $upstream_name=", ngx.var.upstream_name)
end
```
3. access log
```
192.168.235.25 - [192.168.235.25] - - [07/Dec/2021:10:20:10 +0000] "GET
/hostname HTTP/2.0" 200 33 "-" "curl/7.64.0" 48 0.003
[devops_flask-demo-online_8000] 172.16.214.127:8000 33 0.003 200
20d275ca0a73c2f141be75e22254b119 flask-demo.apisix.net [https]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]