开发者

add unique id to requests forwarded from nginx reverse proxy

开发者 https://www.devze.com 2023-01-22 12:21 出处:网络
We are running nginx as a reverse proxy that forwards requests to a Clojure application running Compojure, a library that wraps around Jetty and provides our application with the ability to service we

We are running nginx as a reverse proxy that forwards requests to a Clojure application running Compojure, a library that wraps around Jetty and provides our application with the ability to service web requests.

We currently capture logs generated by both nginx and the Clojure application (via log4j to syslog). We are unable, however, to match an entry in the nginx log to an entry in the syslog开发者_如何学JAVA output of the Clojure application.

We need to figure out a way to modify the request sent upstream to the Clojure app to include some kind of ID. This could be an integer, UUID, whatever.

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

Thanks for your help!


Compojure is written on ring and ring has middleware :)

you would write a middleware called with-uuid that adds the UUID to the request map on the way in and to the reply on the way out.


Of course the best approach would be an nginx module, duplicating the functionality of apache's mod_unique_id.

There doesn't seem to be one yet. Here's a patch that wants to graduate to a module someday.:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号