rejetto forum
Software => HFS ~ HTTP File Server => Topic started by: sergio on October 28, 2017, 03:29:01 PM
-
Hi there! I'm needing some help setting up a macro, to be able to see my visitors IP on the HFS's log. Since I'm using Cloudflare, I currently only see (in the HFS's log) the external IP of Cloudflare, and not the real visitor's IP. Reading the Cloudflare help, I see Cloudflare adds two useful "HTTP headers", like "CF-Connecting-IP:" and "X-Forwarded-For:". Those headers contain the visitors IP. If I only could parse those headers on the HFS's log, that would be awesome. I only need that: reading the "X-Forwarded-For:" value from the HTTP header, and register that on the HFS's log. Cheers!...
-
to query an header entrance there is this macro {.header|xxxxxxxx.}
{.add to log| request
Cloudflare IP : %ip%
CF-Connecting-IP : {.header|CF-Connecting-IP.}
X-Forwarded-For : {.header|X-Forwarded-For.}
.}
-
Thanks Mars.
I enter the code at the beginning of the head tag
Is it the right place?
works well. But when it is entered by direct link, it does not work.
example, mihfs.com/file.zip
How is this resolved?
<head>
{.add to log| request
Cloudflare IP : %ip%
CF-Connecting-IP : {.header|CF-Connecting-IP.}
X-Forwarded-For : {.header|X-Forwarded-For.}
.}
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>{.!HFS.} %folder%</title>
<link rel="stylesheet" href="/?mode=section&id=style.css" type="text/css">
<script type="text/javascript" src="/?mode=jquery"></script>
<link rel="shortcut icon" href="/favicon.ico">
<style class='trash-me'>
.onlyscript, button[onclick] { display:none; }
</style>
<script>
// this object will store some %symbols% in the javascript space, so that libs can read them
HFS = { folder:'{.js encode|%folder%.}', number:%number%, paged:{.!option.paged.} };
</script>
<script type="text/javascript" src="/?mode=section&id=lib.js"></script>
</head>
-
I did not understand what's wrong.
did you get information for the last two lines or are they blank as below?
15:01:38 127.0.0.1:2243 request
> Cloudflare IP : 127.0.0.1
> CF-Connecting-IP :
> X-Forwarded-For :
on the hfs-log, do a right click and select "requests dump" in the "log what" list and you must obtain the list of the complete header as in the log
-
if I enter http://myhfs.com
register the 2 ip correctly
15:01:38 127.0.0.1:2243 request
> Cloudflare IP : 127.0.0.1
> CF-Connecting-IP : correctly
> X-Forwarded-For : correctly
if enter link direct http://myhfs.com/file.zip
only register IP Cloudflare.
it no longer appears:
15:01:38 127.0.0.1:2243 request
> Cloudflare IP : 127.0.0.1
> CF-Connecting-IP : correctly
> X-Forwarded-For : correctly
-
I suppose that http://myhfs.com/file.zip is a direct access to hfs without going through Cloudflare, if it is so, then the headers are not initiated and remain empty
compare the dump requests obtained in the hfs log for both cases, directly by http://myhfs.com/file.zip and trough Cloudflare
-
I just verified that activating in hfs "Requests dump" register IP Cloudflare and visitor correctly. without the need to add the previous code.
I had not noticed that option.
problem solved.
Thanks Mars for your great help.
-
hi guys,
HFS actually supports the x-forwarded-for header.
There's an option that has no part in the GUI, but it is editable in your HFS.INI file.
Search for "forwarded-mask", and put the IP of cloudflare (that you see in the log).