_wordpress-cache in server name

brianmercer nginx-forum at nginx.us
Wed Dec 1 15:49:25 MSK 2010

Ian M. Evans Wrote:
> I saw this example for setting up nginx to run
> wordpress and wp-super cache
> server_name _wordpress-cache mydomain.com;
> root /var/www/wordpress_dir;
> server_name_in_redirect off;
> Can anyone explain to me what the
> "_wordpress-cache" is doing in the
> server name area. Guess I'm trying to wrap my head
> around new config
> options.
> Thanks!
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx

That's my config.  For one site, just remove that _wordpress-cache.

I was using that setup to avoid some issues with using the same
configuration for many sites.  If you're using one server config for a
number of sites like this:

  server_name _wordpress-cache site1.com site2.com site3.com site4.com

Then the first server in the list gets used for certain things.  It's
the HTTP_SERVER variable used in some scripts. It's the "server" that
appears in logs.  It's the "server" that shows up in some email headers.
 So to avoid having site1.com appear for site2.com and site3.com log
entries and email headers, I used to put in a bogus server name to
identify the config.  Although that didn't solve my problem with a
certain php script that used HTTP_SERVER instead of HTTP_HOST.

I'm using another solution now to avoid the problem.  I use a separate
config file for each site and use an include file for the common

server {
  listen xx.xx.xx.xx.xx:80;
  server_name site1.com;
  root /var/www/site1.com;
  access_log /var/log/nginx/site1.com.access.log;
  include /etc/nginx/config/wordpress-cache;

Then you put the entire config in your separate include file and only
have one name listed for server_name.

This is the config:

I should reorganize those and put up a config for WP3 multisite and be
clearer about how to reuse the config for multiple sites.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,154629,154728#msg-154728

More information about the nginx mailing list