<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">That is because it is not: your eyes deceived you having a too quick look at the log line.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Your 'empty' variables are actually showing the value '-' in this log line.<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">It probably does not help debugging to have static '-' mixed in the format of your log lines where you put them.<br></div><div class="gmail_extra"><div><div class="m_3593043300304726828gmail_signature" data-smartmail="gmail_signature"><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div></div>
<br><div class="gmail_quote">On Sun, Mar 5, 2017 at 10:00 PM, c0nw0nk <span dir="ltr"><<a href="mailto:nginx-forum@forum.nginx.org" target="_blank">nginx-forum@forum.nginx.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Francis Daly Wrote:<br>
------------------------------<wbr>-------------------------<br>
<div><div class="m_3593043300304726828h5">> On Fri, Mar 03, 2017 at 10:47:26AM -0500, c0nw0nk wrote:<br>
><br>
> Hi there,<br>
><br>
> > map $http_cf_connecting_ip $client_ip_from_cf {<br>
> > default $http_cf_connecting_ip;<br>
> > }<br>
> ><br>
> > How can I make it so if the client did not send that $http_ header<br>
> it makes<br>
> > $client_ip_from_cf variable value = $binary_remote_addr<br>
> ><br>
> > Not sure how to check in a map if that http header is present.<br>
><br>
> If the http header is absent, the matching variable is empty. So it<br>
> will<br>
> have the value "".<br>
><br>
> Use that as the first half of your "map" pair.<br>
><br>
> f<br>
> --<br>
> Francis Daly <a href="mailto:francis@daoine.org" target="_blank">francis@daoine.org</a><br>
> ______________________________<wbr>_________________<br>
> nginx mailing list<br>
> <a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
> <a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailm<wbr>an/listinfo/nginx</a><br>
<br>
<br>
</div></div>Hey Francis,<br>
<br>
<br>
HTTP BLOCK<br>
log_format cf_custom 'CFIP:$http_cf_connecting_ip - $remote_addr -<br>
$remote_user [$time_local] '<br>
'"$request" Status:$status $body_bytes_sent '<br>
'"$http_referer" "$http_user_agent"'<br>
'$http_cf_ray';<br>
map $status $loggable {<br>
~^[23] 0;<br>
default 1;<br>
}<br>
access_log logs/access.log cf_custom if=$loggable;<br>
<br>
map $remote_addr $client_ip_from_cf {<br>
default $remote_addr;<br>
}<br>
<br>
<br>
Access.log output<br>
CFIP:- - 10.108.22.40 - - [05/Mar/2017:21:27:50 +0100] "GET<br>
<br>
<br>
Any idea why the remote_addr is empty surely it should display to me the<br>
clients IP address i am not proxying traffic or anything like that. I<br>
expected to see an IP there instead it seems the value is empty.<br>
<br>
Posted at Nginx Forum: <a href="https://forum.nginx.org/read.php?2,272744,272766#msg-272766" rel="noreferrer" target="_blank">https://forum.nginx.org/read.p<wbr>hp?2,272744,272766#msg-272766</a><br>
<div class="m_3593043300304726828HOEnZb"><div class="m_3593043300304726828h5"><br>
______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailm<wbr>an/listinfo/nginx</a><br>
</div></div></blockquote></div><br></div></div>