1.背景描述:
1.1项目情况:(可选)
VS开启auto map功能后 ,pool member后端服务无法看到真实的client地址,一般做法是配置x-forwarded-for即可,但现在VS是443,pool是443,由于全程加密,http头部x-forwarded-for字段无法插入,客户需求是需要后端服务器可以看到client地址。
2.故障原因分析:
联系客户,了解到客户在F5上不做卸载,而在服务器侧做卸载,所以在http profile中开启x-forwarded-for插入源地址显然不可行,此问题可以参考红宝书三TCP源地址插入(如下图),将客户端源地址插入tcp option中。
3.解决方案:
3.1操作步骤
1、创建profile(注意:只能在命令行创建,GUI界面无法创建)
create ltm profile tcp PROFILE_NAME tcp-options “{option <first|last>} {option <first|last>}”
eg: create ltm profile tcp tcp-option-28 tcp-options "{28 first }"
2、编写irules
when LB_SELECTED {
set src_cli_addr [IP::client_addr]
}
when SERVER_CONNECTED {
scan $src_cli_addr {%d.%d.%d.%d} e b c d
TCP::option set 28 [binary format cccc $e $b $c $d] all
set tcp_option_content [binary format cccc $e $b $c $d]
log local0. "insert tcp option is $tcp_option_content"
binary scan $tcp_option_content H* cli_addr_H
log local0. "source_ip is $cli_addr_H"
}
3. VS挂载TCP option profile和irules VS类型为Standard
4、可在System->logs下查看插入的源地址,也可在命令行查看
5、抓包验证
注:此方案服务器端获取到的客户端地址格式为16进制
3.2实验验证
1、日志:可以查看源地址是否插入到tcp option中
2、抓包分析
由上图可知,源地址插入成功