需求:当HTTP请求中包含 X-Forwarded-For 的header, 这个值会被策略替换为一个单独的客户端IP地址。如果没有 X-Forwarded header, 将添加这个header并且加入客户端IP地址值。
when HTTP_REQUEST {
if {[HTTP::header exists X-Forwarded-For]}{
HTTP::header replace X-Forwarded-For "[HTTP::header X-Forwarded-For], [IP::
client_addr]"
} else {
HTTP::header insert X-Forwarded-For [IP::client_addr]
}
}
add rewrite action xforward replace HTTP.REQ.HEADER("X-Forwarded-For") CLIENT.IP.SRC
add rewrite policy xforward_check_pol "HTTP.REQ.HEADER(\"X-FORWARDEDFOR\").EXISTS"
add rewrite action xforward_add insert_http_header X-FORWARDED-FOR CLIENT.IP.SRC
add rewrite policy xforward_add_pol "HTTP.REQ.HEADER(\"X-FORWARDEDFOR\").EXISTS.NOT"
xforward_add
全局或者在 vServer 级别绑定
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。