I am configuring varnish for the first time, and I have come across an issue which I haven't been able to find a complete answer for so far.
My config in a nutshell:
server0 - varnish, be1 - apache, be2 - apache
varnish pulls from the 2 backends in a round robin.
I need to deal with sessions, so I have configured a simple php script which sets the current time in a session variable, then redirects to a 2nd page which displays that session variable and the ip of the backend that was used.
I have managed to get this half working. It is passing the session info from what i can see, but here is the problem - the info returned from the backend is specific to the backend it was generated on. So, the time returned will depend on whether be1 or be2 was called for the last cache.
Is there a way that I can get this working so that the session variable is the same regardless of the backend that processes it?
This is the general problem with sessions; a cookie (sent with every request) contains an identifier for the session. The real session data is stored on a server or in a database. There are several solutions for this, e.g.:
Look for some library/reusable code you can apply for your code and good luck!