CloudFoundry / Nginx / Grails和X-Forwarded Header(Missing) [英] CloudFoundry / Nginx / Grails and the X-Forwarded Header (Missing)

查看:125
本文介绍了CloudFoundry / Nginx / Grails和X-Forwarded Header(Missing)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Nginx中使用CloudFoundry,我们试图在Grails中获得X-Forwarded for header,但我们似乎无法这样做。它可以是空白的,也可以是Nginx服务器的IP地址。

Using CloudFoundry with Nginx, we're trying to get the X-Forwarded for header out in grails, but we can't seem to do so. It's either blank or the IP address of the Nginx server.

我们经常创建允许用户投票的网站,我们希望确保他们只投一次。因此,我们希望使用他们的网络网关(路由器)IP地址和他们的X-Forwarded-For(内部)IP地址的组合,以便我们可以检查人们是否已经投票,而不必阻止他们的整个网络投票因为一票。

We often create sites where users are allowed to vote, and we want to be sure that they only vote once. Therefore, we'd like to use a combination of their network gateway (router) ip address and their X-Forwarded-For (internal) ip address so that we can check if people have already voted without having to block their entire network from voting because of one vote.

不幸的是,由于用户倾向于使用incogneto窗口进行投票,因此Cookie被证明不可靠。使用本地存储也被证明是不成功的,因为客户倾向于删除他们的网站数据以便再次投票。唯一的另一种选择是强制他们创建一个帐户并验证他们的电子邮件地址,这太难以进入。

Unfortunately cookies have proven unreliable as users tend to use incogneto windows to make their votes. Using local storage has also proved unsuccessful as clients tend to delete their "website data" in order to vote again. The only other option is forcing them to create an account and verify their email address which is too much of a barrier to entry.

有没有办法我们可以得到一个或者有没有一种方法可以在Nginx上创建一个服务,我们可以通过查询获取请求的X-Forwarded-For头,或者我们可以创建一个X-Forwarded-For头一个插件让Nginx创建一个新的头文件(X-Nginx-Forwarded-For)?

Is there a way that we can get a list of X-Forwarded for IP's in the chain (without Nginx stealing them), or is there a way we can create a service on Nginx that we can query to get the X-Forwarded-For header for the request, or can we create a "plugin" for Nginx to create a new header (X-Nginx-Forwarded-For)?

推荐答案

与Nginx合作,但看起来您可以非常轻松地将自定义标头添加到代理请求到终端服务器。 http://wiki.nginx.org/HttpProxyModule

I've never worked with Nginx, but it looks like you can add custom headers to the proxied request to the end server very easily. http://wiki.nginx.org/HttpProxyModule

这篇关于CloudFoundry / Nginx / Grails和X-Forwarded Header(Missing)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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