WordPress.org

Ready to get started?Download WordPress

Plugin Directory

WordPress Varnish

WordPress Varnish is a simple plugin that purges new and edited content.

Does this just work?

Yes.

But how should my varnish configuration file look like?

I have provided a simple VCL that can be used as a reference.

Does it work for Multi-Site (or WPMU)?

Yes. Activating the plugin site-wide will provide the functionality to all blogs. Configuration can be done on the blogs individually, or can be global. If you want to configure Varnish servers globally, edit wp-config.php and include these lines just before "That's all, stop editing!" message:

global $varnish_servers; $varnish_servers = array('192.168.0.1:80:secret','192.168.0.2:80:secret'); define('VARNISH_SHOWCFG',1);

The varnish servers array will configure multiple servers for sending the purges. If VARNISH_SHOWCFG is defined, configuration will be shown to all users who access the plugin configuration page (but they can't edit it).

My Plugins are seeing the Varnish server's IP rather than the websurfer IP

You could install Apache's mod_rpaf module: http://stderr.net/apache/rpaf/

or, in wp-config.php, near the top, put the following code:

$temp_ip = explode(',', isset($_SERVER['HTTP_X_FORWARDED_FOR'])
? $_SERVER['HTTP_X_FORWARDED_FOR'] :
(isset($_SERVER['HTTP_CLIENT_IP']) ?
$_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR']));
$remote_addr = trim($temp_ip[0]);
$_SERVER['REMOTE_ADDR'] = preg_replace('/[^0-9.:]/', '', $remote_addr );

The code takes some of the common headers and replaces the REMOTE_ADDR variable, allowing plugins that use the surfer's IP address to see the surfer's IP rather than the server's IP.

Requires: 2.9.2 or higher
Compatible up to: 3.6.1
Last Updated: 2013-9-13
Downloads: 7,359

Ratings

4 stars
4 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

50,2,1
75,4,3
100,1,1
0,1,0
0,1,0
0,1,0
100,1,1 100,1,1 100,1,1
100,1,1