Skip to content

关于higresss使用中的一些问题(host和log的问题咨询) #2037

Open
@jujiale

Description

@jujiale

社区各位大佬好,在使用higress开发插件的过程中,遇到两个问题想咨询下:
host 问题咨询
客户端请求higress的时候,header中带了host域名,对应路由的upstream是一个static的固定地址,请求转发到上游的时候,host变成了upstream的ip,而不是客户端请求header中的host,我仔细看了下,真正客户端请求的host,在一个叫:x-envoy-original-host的header中, 如何才能让请求经过higress到达upstream时,请求的host依旧保持和客户端请求higress的host一致

access_log问题咨询
如下是higress记录自定义日志的方式:

ctx.SetUserAttribute("k3", 123)
_ = ctx.WriteUserAttributeToLogWithKey(“ai_log”)

ctx.SetUserAttribute("k4", 123)
_ = ctx.WriteUserAttributeToLogWithKey(“custom_log”)

key可以是ai_log或custom_log

同时在configmap中access_log的字段定义如下:
"ai_log":"%FILTER_STATE(wasm.ai_log:PLAIN)%","custom_log":"%FILTER_STATE(wasm.custom_log:PLAIN)%"

如果我在同一个插件中,既需要给ai_log又需要给custom_log这两个key中记录日志,那在ctx.SetUserAttribute("k3", 123)的时候,因为最终调用:ctx.WriteUserAttributeToLogWithKey(key),传递的key使用的UserAttribute是同一个ctx的,目前看下来是custom_log和ai_log会记录双份

那么是否有办法,在一个插件里面,可以既给ai_log又给custom_log中记录日志,还是说在一个插件中,只能给一个自定义的key中写日志

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