Jump to: navigation, search

Other languages:
English • ‎español • ‎français • ‎日本語 • ‎polski • ‎português do Brasil
Squid: $wgSquidServers
An array of individual proxy servers to help MediaWiki detect if the request has been proxyed.
But also to send back to the proxy PURGE commands on changes.
Introduced in version: 1.2.0
Removed in version: still in use
Allowed values:
Default value: array()
Prior to 1.4.0 no default value was set.

Other settings: Alphabetical | By Function

Although this variable has the word Squid in it, it can also be used with other caching proxies, like Varnish.

Details[edit | edit source]

This variable is about telling MediaWiki what are the individual IP adresses of each Proxy servers that serves content to your visitors.

Note that if you have CIDR ranges (e.g., make sure you set them in $wgSquidServersNoPurge instead.

The setting can be used in many Proxy setups, both within a private network or through an external provider, and also with external services that are based on either Varnish or Squid.

Configuration example with Varnish[edit | edit source]

Consider the following setup details:

  • one and/or more web servers ("origins") with MediaWiki running
  • Varnish configuration points to your MediaWiki origins
  • You have a few Varnish servers that proxies requests for the web servers
  • You have a list of single IP addresses (not CIDR ranges, that would go in $wgSquidServersNoPurge instead!)

Here are the configurations you have to set in place:

  • In Varnish, set a X-Forwarded-For HTTP header with client.ip, example:
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip
  • Create an array of servers. Ideally it should be IP in decimal format but those would work
// In LocalSettings.php
$wgUseSquid = true;
$wgSquidServers = array();
$wgSquidServers[] = ""; 
$wgSquidServers[] = "";
$wgSquidServers[] = "";
$wgSquidServers[] = "";  // Also works if you have a DNS configured on every MW origins. But its not recommended.
#$wgSquidServers[] = "";       // WON’T WORK, refer to $wgSquidServersNoPurge

Note Note: The following IP are for example purpose, defined in from <|>RFC 5737</>.

TODO: Insert example of a valid IPv6 address that is part of 2001:DB8::/32 range as per RFC3849

Usage notes and history[edit | edit source]

  • Don't specify port number (This could be wrong.)
  • Any IPs listed in this array will be treated as trusted surrogates (reverse proxies)
  • IP addresses displayed for users connected via these Squid/Varnish servers therefore will match individual user IP's, not the Squid's IP.

Note Note: In versions prior to 1.4.0 this setting was not defined in DefaultSettings.php (although its usage was commented there). This may have been because it wasn't implemented properly or may simply have been an oversight.

Format[edit | edit source]

  • Each entry can be either IPv6/IPv4 addresses in octal format (e.g.
  • CIDR notation and ranges should be configured in $wgSquidServersNoPurge

Anything described in includes/utils/IP.php should be valid.

See also[edit | edit source]