Nik
Nik

Reputation: 21

varnish 3 and multiple IPs (virtualhosts) isn't working out too well for me

Complete newbie to Varnish so apologies ahead of time if this seems rather silly.

Here's the situation. I have a server with 5 IPs. Using ISPconfig for most tasks but that's probably irrelevant.

I have multiple apache virtual hosts configured across multiple IPs.

The issue is that varnish is putting out a 503, fetch error no backend connection (according to varnishlog) on any of the non-default virtual hosts i.e. ones with a static IP defined in vhosts. Any *:8080 vhosts are working ok. So I'm missing something somewhere. All of the vhost error logs show file does not exist errors though the path looks correct.

Suggestions are much appreciated.

I have of course manually edited all vhost entries and configured them accordingly i.e.

<VirtualHost 00.11.22.33:8080>
      DocumentRoot /var/www/shop.example1.com/web

Here's my vcl config

    backend default {

        .host = "127.0.0.1";
        .port = "8080";
    }

    backend example1 {
          .host = "00.11.22.33";
          .port = "8080";
    }

    backend example2 {
         .host = "11.22.33.44";
          .port = "8080";
    }


    acl purge {
            "localhost";
    }

    sub vcl_recv {

    if (req.http.host ~ "(?i)^(www.)?example1.com")

    {

        set req.http.host = "www.example1.com";
        set req.backend = example1;

    }

    if (req.http.Host ~ "shop\.example2\.com") 
    {

            set req.http.Host = "shop.example2.com";
            set req.backend = example2;


            }
        set req.grace = 2m;

  set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*", "");
  set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");




if (req.url ~ "/wp-(login|admin|cron)") {
        return (pass);
}


set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", "");

set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?", "");

set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(; )?", "");

if (req.url ~ "wp-content/themes/" && req.url ~ "\.(css|js|png|gif|jp(e)?g)") {

.......
'

Upvotes: 0

Views: 1720

Answers (1)

Nik
Nik

Reputation: 21

Damn obvious thing of course.

port.conf had:

    NameVirtualHost *:8080
Listen 127.0.0.1:8080

What it needed was:

NameVirtualHost *:8080
Listen 127.0.0.1:8080
Listen my_IP1:8080
Listen my_IP2:8080

Upvotes: 1

Related Questions