为从nginx反向代理转发的请求添加唯一ID [英] add unique id to requests forwarded from nginx reverse proxy

查看:1216
本文介绍了为从nginx反向代理转发的请求添加唯一ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们运行nginx作为反向代理,将请求转发给运行Compojure的Clojure应用程序,该应用程序环绕Jetty并为我们的应用程序提供服务Web请求的能力。

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.

我们当前捕获由nginx和Clojure应用程序生成的日志(通过log4j到syslog)。但是,我们无法将nginx日志中的条目与Clojure应用程序的syslog输出中的条目匹配。

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 output of the Clojure application.

我们需要找出一种方法来修改该请求向上游发送到Clojure应用程序以包括某种ID。这可以是一个整数,UUID,无论如何。

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?

感谢您的帮助!

推荐答案

Compojure写在戒指上,戒指有中间件:)

Compojure is written on ring and ring has middleware :)

你会写一个名为的中间件,用-uuid 将UUID添加到请求映射中

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.

这篇关于为从nginx反向代理转发的请求添加唯一ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆