WordPress.org

Ready to get started?Download WordPress

Forums

Multisites and Varnish setup (3 posts)

  1. alittlebitofnothing
    Member
    Posted 1 year ago #

    Hello everyone.

    I have a WordPress multisite with around 100 sites, many of which use their own domains mapped using Donncha's plugin. Users map an A record in their DNS manager to our dedicated IP.

    I want to install Varnish and I have this running on a similar setup but it only has 2 sub sites with their own domain:

    ports.conf

    # NameVirtualHost 127.0.0.1:8080
    Listen 127.0.0.1:8080
    Listen 127.0.0.1:8000

    /etc/apache2/sites-enabled/zz-mass-hosting

    NameVirtualHost 127.0.0.1:8080
    <VirtualHost 127.0.0.1:8080>

    /etc/apache2/sites-enabled/zz-mass-hosting.212.110.XXX.XXX ** is the multisite_ip

    NameVirtualHost 127.0.0.1:8000
    <VirtualHost 127.0.0.1:8000>
    ServerName mysite.co.uk:8000

    /etc/default/varnish points

    DAEMON_OPTS points to the 2 ips on port 80

    I have set up the vcl with 2 backends:

    backend default {
    .host = "127.0.0.1";
    .port = "8080";
    }

    # For 2nd IP Address setting Apache Backend to 127.0.0.1:8000

    backend mysite {
    .host = "127.0.0.1";
    .port = "8000";
    }

    On my test installation I only have 2 sites mapped to their own domains, so I have this:

    # choose a backend depending on domain
    if (req.http.host ~ "myothersite.co.uk") {
    set req.backend = mysite;
    }
    if (req.http.host ~ "andanotherone.com") {
    set req.backend = mysite;
    }else{
    set req.backend = default;
    }

    Seems to be working OK right now.

    But on the new installation I have a heck of a lot of sites to map, so my question is whether there's a snappy way around this without lots of typing or manual intervention each time a new site is mapped to its own domain (I don't always know this)?

    Alternatives on a postcard.

    Thanks in anticipation ...

  2. tomontoast
    Member
    Posted 1 year ago #

    You'll probably get more of a response on the Varnish forums https://www.varnish-cache.org/forum/1

    You are welcome to post here but this is above what most people are comfortable with including me. But I guess you could write a script to generate the domain mapping based on some data in a database table.

  3. alittlebitofnothing
    Member
    Posted 1 year ago #

    I only asked here since it is a problem that might affect anyone with multisites and using domain mapping and wanting a bit of varnish, plus often good answers here and in plain english ;)

    but you are probably right and will head over there and see what they advise

    thanks

    em

Topic Closed

This topic has been closed to new replies.

About this Topic