Hi:<div><br></div><div>When duplicate http headers occur(e.g., two X-Forwarded-For headers), nginx will use the first instance silently. This means internal variables like $http_x_forwarded_for is not entirely <i>correct,</i> users have to capture packets in the network layer to find out the truth. This is a lot of inconvenient compared to customize log format.</div>
<div><br></div><div>Also, for headers like &quot;X-Forwarded-For&quot;, attackers can intentionaly inject serveral spoofed ip addresses.</div><div><br></div><div>Although nginx cannot possibly known which one is more important than the others, it MAY alert user by logging &quot;duplicated headers detected, header:value1, value2, ... value N&quot;.</div>
<div><br></div><div>Currently, we use nginx-lua module to detect duplicate headers, like:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>itable = ngx.req.get_headers()[&quot;X-Forwarded-For&quot;]</div>
<div>for k, v in iparis(itable) do</div><div>  -- process duplicate header</div><div>end</div></blockquote><div><br></div><div><br clear="all"><br>-- <br>lei yang<br>
</div>