IIS下Advanced Logging(高级日志)的安装以及X-Forwarded-For的配置

本文详细介绍了如何在 IIS 中启用并配置高级日志记录功能,包括下载安装包、设置日志字段及定义日志文件名等步骤,并提供重启 IIS 的命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下载地址:https://www.microsoft.com/en-gb/download/details.aspx?id=7211

1.启动IIS管理器,然后点击左侧的服务器名称,(注意:不要点击网站下的站点或虚拟目录,否则找不到下面的” Enable Advanced Logging”);

2.在主页中,双击IIS下的” Advanced Logging”;

3.点击右侧操作窗格中的” Enable Advanced Logging”(启用高级日志);

4.继续点击右边操作窗格中的“Edit Logging Fields”(编辑日志字段);

5.在” Edit Logging Fields”窗口中,单击”Add Field”(添加字段),然后对应输入以下信息;

Field ID输入”ClientSourceIP”;

Category选择”Default”;

Source type选择”Request Header”;

Source name输入”X-Forwarded-For”;

6.点击右边操作窗格中的”Add Log Definition”(添加日志定义);

7.在”Base file name”字段中输入“Client Source IP”;然后点击”Select Fields”按钮,并选择”ClientSourceIP”;最后点击”应用”,回到主页;

8.重启IIS(iisreset命令)。

 注:查看日志路径点击”View Log Files”。

 

欢迎批评指正。

原文地址:http://www.cnblogs.com/zhangtingzu/p/7300457.html

参考文献:https://www.loadbalancer.org/blog/iis-and-x-forwarded-for-header/

 

转载于:https://www.cnblogs.com/zhangtingzu/p/7300457.html

### X-Forwarded-For Header Purpose and Usage The `X-Forwarded-For` (XFF) header is a de facto standard header for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer. This header allows services behind proxies, such as Network Load Balancers[^1], to reconstruct the original request path from client to destination. When requests pass through intermediaries like proxies or load balancers, the source IP seen by the final server would be that of the last intermediary rather than the actual user's IP. The `X-Forwarded-For` header appends the IP addresses of each network hop encountered along the way so developers can trace back to the initial requester’s public IP address. #### Example Implementation in Code In many programming languages and frameworks, accessing this value involves checking headers sent with incoming HTTP requests: ```python from flask import Flask, request app = Flask(__name__) @app.route('/') def index(): # Get list of IPs from X-Forwarded-For header forwarded_for = request.headers.get('X-Forwarded-For') if forwarded_for: ip_addresses = forwarded_for.split(',') first_ip = ip_addresses[0].strip() return f'First IP Address: {first_ip}' else: return 'No X-Forwarded-For header present' if __name__ == '__main__': app.run(debug=True) ``` This example demonstrates how one might extract and process information contained within the `X-Forwarded-For` header using Python and Flask framework. --related questions-- 1. How do different types of load balancers affect the handling of X-Forwarded-For headers? 2. What security considerations should be taken into account when relying on X-Forwarded-For data? 3. Can you provide examples where not properly configuring X-For could lead to issues in logging or analytics systems?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值