Posted in: Uncategorized

WordPress Comments and varnish

The problem I Found was that I could not post on http – I was getting an error 405.  this was due to a problem with the way varnish was caching the comments-post.php page from wordpress.  so I made a change to not cache this – add a if option to return(pipe) on the comments-post.php page, and I was able to post comments however, I then found two more problems:  Firstly that the recorded IP of the poster was from the proxy, not their real IP, and secondly that the name and email was auto populated to all visitors from the same IP (I think this was a cookie problem).

The first issue is fixed by adding a pre-pend for the php server to re-define the $_SERVER[‘REMOTE_ADDR’] variable as defined in by the X-Forwarded-For header which has been defined in the ngnix / varnish proxies.

The second issue is to do with the way varnish handles cookies, rather than debug this (I found varnish config files hard to follow) I have decided to switch away from varnish and just use ngnix to handle the reverse proxies.  In many ways this is better as I end up only using one product to handle reverse proxying.

I added config to ngnix to handle 2 virtual servers