Mailing List Archive

Passing through client IP address to server
Im running both Varnish and my LAMP application on the same machine, so
all requests hitting the apache server now have an incoming IP address
of 127.0.0.1.

Is there something that I can do in VCL to set the client IP address
that apache sees as being the real client IP address ?

My PHP app has a requirement to record both client IP address,
timestamp, and browser version for all accesses to the system, so I
eventually need to make this happen.

Thnks
SteveOC


Apologies if this topic has been covered before - Ive done a good search
using google, and couldnt find an answer to this one .. thanks.
Passing through client IP address to server [ In reply to ]
ADOFMS Admin, SteveOC wrote:
> Im running both Varnish and my LAMP application on the same machine, so
> all requests hitting the apache server now have an incoming IP address
> of 127.0.0.1.
>
> Is there something that I can do in VCL to set the client IP address
> that apache sees as being the real client IP address ?
>
> My PHP app has a requirement to record both client IP address,
> timestamp, and browser version for all accesses to the system, so I
> eventually need to make this happen.

Take a look at the X-Forwarded-for header.

--
Kenneth R?rvik, IT HiO
Tlf 22 45 20 83
Kenneth.Rorvik at hio.no
Passing through client IP address to server [ In reply to ]
----- ADOFMS Admin, SteveOC <admin at adofms.com.au> wrote:
> There is also a HTTP_X_VARNISH variable set as well, which is just a
> number. Any idea what this one does ?

This number is a request number you can use for debugging.
varnishlog outputs these identifiers and you can cross check with the number from the header.

Regards
--
Denis Braekhus - Teknisk Ansvarlig ABC Startsiden AS
http://www.startsiden.no
Passing through client IP address to server [ In reply to ]
Kenneth R?rvik wrote:
> ADOFMS Admin, SteveOC wrote:
>> Im running both Varnish and my LAMP application on the same machine, so
>> all requests hitting the apache server now have an incoming IP address
>> of 127.0.0.1.
>>
>> Is there something that I can do in VCL to set the client IP address
>> that apache sees as being the real client IP address ?
>> My PHP app has a requirement to record both client IP address,
>> timestamp, and browser version for all accesses to the system, so I
>> eventually need to make this happen.
>
> Take a look at the X-Forwarded-for header.
>
Brilliant !!

Got it now, didnt notice that being set before. but that will do the trick.

There is also a HTTP_X_VIA being set sometimes, which reports the
hostname of the client machine. This variable isnt set on every request
though.

There is also a HTTP_X_VARNISH variable set as well, which is just a
number. Any idea what this one does ?
Passing through client IP address to server [ In reply to ]
"ADOFMS Admin, SteveOC" <admin at adofms.com.au> writes:
> There is also a HTTP_X_VIA being set sometimes, which reports the
> hostname of the client machine. This variable isnt set on every request
> though.

X-Via most likely comes from a downstream cache, possibly a client-side
Squid cache or something similar.

> There is also a HTTP_X_VARNISH variable set as well, which is just a
> number. Any idea what this one does ?

It is a reference to the internal request ID, which is recorded in the
log file. For a cache hit, X-Varnish will contain both the ID of the
current request and the ID of the request that populated the cache. It
makes debugging Varnish a *lot* easier.

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no