Add unique identifier to requests redirected from nginx reverse proxy

We run nginx as a reverse proxy, which redirects requests to a Clojure application that runs Compojure, a library that wraps Jetty and provides our application with the ability to serve web requests.

We are currently logging logs created by both nginx and the Clojure application (via log4j in syslog). However, we cannot match the nginx log entry with the syslog output of the Clojure application.

We need to figure out how to modify the request sent upstream in the Clojure application to include some kind of identifier. It can be an integer, UUID, whatever.

Do you have any suggestions on how best to accomplish this?

Thank you for your help!

+3
source share
2 answers

Compojure is recorded on the ring, and the ring has middleware :)

you must write a middleware called with-uuidthat adds the UUID to the request card along the way in and to the response on the output.

+4
source

Of course, a nginx module duplicating apache mod_unique_id functionality would be a better approach.

It seems like not yet. Here is a patch that someday wants to finish a module.

http://mailman.nginx.org/pipermail/nginx-devel/2011-June/001015.html

+2
source

Source: https://habr.com/ru/post/1771831/


All Articles