欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

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

程序员文章站 2022-12-07 20:34:09
一、设置x-forwarded-for段 nginx配置示例:复制代码 代码如下:server{   location   { &...

一、设置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!