Skip to content

How to print the client's original request URL in the logs instead of the rewritten URL #38812

Open
@wuzhuoquan

Description

@wuzhuoquan

Title: One line description

Description:
I wanted to print the client's original request URL in the logs, so I used request_url: '%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%' in logFormat to output it to the logs. Later, I discovered that the X-ENVOY-ORIGINAL-PATH header was also being forwarded to the server. In cases where the URL contains many parameters or is particularly long, this could cause the header to become too large and result in a 431 error. Therefore, I used suppress_envoy_headers to remove this header.
However, after making this change, I noticed that the request_url field in the logs no longer shows the original path from the client request, but instead shows the path after Envoy's rewrite. For example, when a client requests /payment/v1/list, it gets rewritten to /payment/list before being sent to the server, and at this point the printed request_url is /payment/list instead of /payment/v1/list. This behavior is very different from Nginx. Could you please help me how to print the client's original path while still using suppress_envoy_headers to remove the X-ENVOY-ORIGINAL-PATH header? Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/access_logquestionQuestions that are neither investigations, bugs, nor enhancementsstalestalebot believes this issue/PR has not been touched recently

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions