让iis记录nginx反向代理的真实ip

iis放在反向代理后面时,日志里的c-ip是反向代理服务器的ip,不是真正用户的ip,如果需要记录用户的ip,请参考如下的介绍

一、设置X-Forwarded-For段

nginx配置示例:

server
{
   location
   {
     ...
     proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
     ...
   }

二、在iis站点上安装isapi filter

在f5的开发论坛上找到的,按开发者的话说,是为了解决iis放在f5后记录不到用户ip的问题,管他前端是f5还是nginx还是squid还是haproxy,都可以用。
装完之后重启下iis即可。

https://devcentral.f5.com/weblogs/Joe/archive/2009/08/19/x_forwarded_for_log_filter_for_windows_servers.aspx

安装方法,从官方文档复制了过来的,大家看看咯。
Installation

Follow these steps to install the filter.

Download and unzip the F5XForwardedFor.zip distribution.
Copy the F5XForwardedFor.dll file from the x86\Release or x64\Release directory (depending on your platform) into a target directory on your system. Let's say C:\ISAPIFilters.
Ensure that the containing directory and the F5XForwardedFor.dll file have read permissions by the IIS process. It's easiest to just give full read access to everyone.
Open the IIS Admin utility and navigate to the web server you would like to apply it to.
For IIS6, Right click on your web server and select Properties. Then select the "ISAPI Filters" tab. From there click the "Add" button and enter "F5XForwardedFor" for the Name and the path to the file "c:\ISAPIFilters\F5XForwardedFor.dll" to the Executable field and click OK enough times to exit the property dialogs. At this point the filter should be working for you. You can go back into the property dialog to determine whether the filter is active or an error occurred.
For II7, you'll want to select your website and then double click on the "ISAPI Filters" icon that shows up in the Features View. In the Actions Pane on the right select the "Add" link and enter "F5XForwardedFor" for the name and "C:\ISAPIFilters\F5XForwardedFor.dll" for the Executable. Click OK and you are set to go.
I'd love to hear feedback on this and if there are any other feature request, I'm wide open to suggestions. The source code is included in the download distribution so if you make any changes yourself, let me know!

Good luck and happy filtering!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

一:确定你的系统是UTF编码 [root@Tserver ~]# env|grep LANG LANG=en_US.UTF-8 二:NGINX配置文件里默认编码设置为utf-8 server { listen 80; server_name .inginx.com ; index index.html index.htm index.php; root /usr/local/nginx/html/inginx.com; ch
很多网站需要采用伪静态来访问动态网页。所以像phpcms这样的系统,都提供了一个.htaccess文件,供写伪静态规则。但这个规则是针对Apache的。在nginx服务器上并不起作用。 nginx 可以直接将伪静态规则写在配置文件中,但这个需要有服务器管理权限,普通站长不
随着智能手机的普及,越来越多的人使用手机上网,很多网站也应手机上网的需要推出了网站客户端,.apk文件就是安卓(Android)的应用程序后缀名,默认情况下,使用IIS作为Web服务器的无法下载此文件,那么怎么才能让IIS支持.apk文件的下载呢? IIS服务器不能下
在网站建设中需要网页重定向的情况很多:如网页目录结构变动,网页重命名、网页的扩展名改变、网站域名改变等。如果不做重定向,用户的收藏和搜索引 擎数据库中的旧地址只能让访客得到一个404错误信息页面,访问流量白白丧失。不仅如此,之前该页面的一切积
对于IIS报503的问题相信大家都很熟悉了,博客园以前也经常503,但这个问题不好排查,前几天我也为503问题烦恼,总结了一些排查思路和大家分享,但最终还没有解决问题,请大家有懂的也赶紧指点指点。 网上有人发贴说可能与应用程序池的进程回收设置有关,建议
利用nginx泛域名解析配置二级域名和多域名 网站的目录结构为 html ├── bbs └── www html为nginx的安装目录下默认的存放源代码的路径。 bbs为论坛程序源代码路径 www为主页程序源代码路径 把相应程序放入上面的路径通过 http://www.youdomain.com 访问