大网数据广告活动
服务器运维问答

Apache: X-Request-ID like in Heroku

· 52CE 我爱测

I like X-Request-ID : The Heroku router generates a unique request ID for every incoming HTTP request that it receives. This unique ID is then passed to your application as an HTTP header called X-Request-ID. From https://devcent…

问题原文

原帖链接 · guettli · CC BY-SA 3.0

I like X-Request-ID:

The Heroku router generates a unique request ID for every incoming HTTP request that it receives. This unique ID is then passed to your application as an HTTP header called X-Request-ID.

From https://devcenter.heroku.com/articles/http-request-id

How can I configure Apache to provide X-Request-ID which is different, even if a multi-threaded MPM gets used?

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 3.0

You need to do two things:

  1. Load the unique_id_module. This provides the UNIQUE_ID environment variable which serves this purpose.

    LoadModule mod_unique_id.c
    
  2. Copy the UNIQUE_ID into the X-Request-ID header in the appropriate virtual host using the RequestHeader directive.

    RequestHeader setifempty X-Request-ID %{UNIQUE_ID}e
    ProxyPass ...
    ProxyPassReverse ...
    

Optionally, you can also put %{UNIQUE_ID}e into a custom log format so that you can log it from Apache (possibly in addition to within your application).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-08-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。