I would like to add a unique id to each request done through apache which will be used in the access log and is forwarded to underlying systems in a header to be used in their logs.
What is the best solution to accomplish this?
In Linux, Apache commonly writes logs to the /var/log/apache2 or /var/log/httpd directories depending on your OS and Virtual Host overrides. You can also define a LogFormat string after the filename, which will only apply the format string to this file.
In HTTP, "Referer" (a misspelling of Referrer) is the name of an optional HTTP header field that identifies the address of the web page (i.e., the URI or IRI), from which the resource has been requested. By checking the referrer, the server providing the new web page can see where the request originated.
mod_unique_id will provide an environment variable UNIQUE_ID
with a unique identifier for each request.
You can add it to request headers with:
RequestHeader set uniqueid %{UNIQUE_ID}e
If you add that header to apache logs, for example:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{uniqueid}i\"" combined
you willl get something like:
10.0.2.2 - - [01/Nov/2016:23:12:40 +0000] "GET /index.html HTTP/1.1" 404 208 "WBkhaJRMNmj7U9aiFl2pzQAAAAA"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With