Baoyuantop commented on issue #11337: URL: https://github.com/apache/apisix/issues/11337#issuecomment-2819883165
The reason the `$req_header` variable does not work is that it is not a standard APISIX variable or an NGINX built-in variable. If you want to get request header information, you need to use the correct variable format. To get the request header information, you should use the `$http_*` format, where * is the name of the request header (lowercase, and the hyphen - is replaced with an underscore _). Example: - Get User-Agent header: use $http_user_agent - Get Content-Type header: use $http_content_type - Get X-Real-IP header: use $http_x_real_ip If you need to get specific response headers in a custom log_format, you can use the `$sent_http_*` prefix. The best way to do this is to use the default full log format, which will automatically include all request headers. If the default format contains too much information you don't need, you can process and filter the data on the server side that receives the log. If you really need to customize the format and include all request headers, you may need to develop a custom plugin to meet this specific need. https://nginx.org/en/docs/http/ngx_http_core_module.html#var_http_ https://nginx.org/en/docs/http/ngx_http_core_module.html#var_sent_http_ -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org