Jump to content

Installing varnish - need configuration help


Recommended Posts

Posted

# yum reinstall varnish --nogpgcheck

installs version 2.1.5-1 x86_64 on centos5.5 64bit

I am then following the instructions by editing /etc/varnish/default.vcl and changing

# backend default {

#     .host = "127.0.0.1";

#     .port = "8080";

# }

to

backend default {

      .host = "127.0.0.1";

      .port = "80";

}

I am then doing the test to get varnish started # pkill varnishd # varnishd -f /etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000 -a 0.0.0.0:8080 I go to http://myipaddress:8080 in a browser and it times out using varnishlog, All I see is

0 CLI          - Rd ping

0 CLI          - Wr 200 PONG 1273698726 1.0


as in the example given at http://www.varnish-cache.org/docs/2.1/tutorial/logging.html

I do not see any changes as part of my second stage.
This install is on a production machine. What am I missing or doing wrong?

Posted

May sound silly, But is that port open, Looks like the install went fine as it would have gives some error reporting, So to me, When you say timeout, It means something is there just not calling back. Check the port status first :)

Posted

May sound silly, But is that port open, Looks like the install went fine as it would have gives some error reporting, So to me, When you say timeout, It means something is there just not calling back. Check the port status first :)




thanks Gary, that was inded the issue. Its always good to get a second pair of eyes to check for the obvious.
Now the logging works when I do the tests, but when it comes to moving it over to port 80 for production, when I restart httpd and then varnish I get the following.

# service varnish restart

: command not foundish: line 6:

: command not foundish: line 9:

: command not foundish: line 13:

: command not foundish: line 16:

: command not foundish: line 23:

: command not foundish: line 25:

: command not foundish: line 36:

: command not foundish: line 37:

: command not foundish: line 50:

: command not foundish: line 51:

: command not foundish: line 105:

: command not foundish: line 106:


Stopping varnish HTTP accelerator:                         [FAILED]

: invalid number HTTP accelerator: /etc/init.d/varnish: line 54: ulimit: 131072

: invalid numberish: line 57: ulimit: 82000

Posted

my default.vcl is

backend default {

  .host = "127.0.0.1";

  .port = "8080";

}


sub vcl_recv {


  ## == Mobile ==

  if (req.http.User-Agent ~ "(iPad|iPhone|iPod|Android|SymbianOS|^BlackBerry|^SonyEricsson|^Nokia|^SAMSUNG|^LG)") {

    return(pass);

  }


  if (!((req.http.Cookie ~ "member_id=" && req.http.Cookie !~ "member_id=(0|-1)") || req.http.Cookie ~ "(guestSkinChoice|language)"))  {

    if (req.url ~ "^/(public|forum|topic|gallery|blogs|members|user|calendar)/") {

      unset req.http.cookie;

      set req.grace = 15s;

    }

  }

}


sub vcl_fetch {

  if (!((req.http.Cookie ~ "member_id=" && req.http.Cookie !~ "member_id=(0|-1)") || req.http.Cookie ~ "(guestSkinChoice|language)")) {


    ## == ESI ==


    if (req.url ~ "^/(gallery/image|topic)/") {

      esi;

      unset beresp.http.set-cookie;

      set beresp.ttl = 300s;

      set beresp.grace = 30s;


    ## == Others ==


    } elseif (req.url ~ "^/(public|forum|gallery|blogs|members|user|calendar)/") {

      unset beresp.http.set-cookie;

      set beresp.ttl = 600s;

      set beresp.grace = 30s;

    }

  }

}


sub vcl_deliver {

  remove resp.http.X-Varnish;

  remove resp.http.Via;

  remove resp.http.Age;

  remove resp.http.X-Powered-By;


  if (obj.hits > 0) {

    set resp.http.X-Cache = "HIT";

  } else {

    set resp.http.X-Cache = "MISS";

  }

}

Posted

Try this:

/etc/init.d/httpd stop



Then

/etc/init.d/varnish stop



Then

/etc/init.d/varnish restart



/etc/init.d/httpd restart




Maybe some processes were still running causing varnish not to start, Litespeed does the same output if apache processes cannot die.
Posted

I done this on local host and it worked fine with the following:

You can test at your own risk !

yum install varnish.x86_64



or

yum install varnish



Both bring same package !

Now edit / Make the default VLC file:

vi /etc/varnish/default.vcl




I used:

backend default {


.host = "127.0.0.1";


.port = "80";


}



I just then started the daemon including the LOG to check what the issues are if any:

# /etc/init.d/varnish start


# /etc/init.d/varnishlog start

Posted

I done this on local host and it worked fine with the following:



You can test at your own risk !



Both bring same package !



Now edit / Make the default VLC file:





Thanks Gary.
With the VCL you set it works fine. Now the problem occurs when I use the vcl configuration I've been given to use.

# This is a basic VCL configuration file for varnish.  See the vcl(7)

# man page for details on VCL syntax and semantics.

# 

# Default backend definition.  Set this to point to your content

# server.

# 


backend default {

  .host = "127.0.0.1";

  .port = "8080";

}


sub vcl_recv {


  ## == Mobile ==

  if (req.http.User-Agent ~ "(iPad|iPhone|iPod|Android|SymbianOS|^BlackBerry|^SonyEricsson|^Nokia|^SAMSUNG|^LG)") {

    return(pass);

  }


  if (!((req.http.Cookie ~ "member_id=" && req.http.Cookie !~ "member_id=(0|-1)") || req.http.Cookie ~ "(guestSkinChoice|language)"))  {

    if (req.url ~ "^/(public|forum|topic|gallery|blogs|members|user|calendar)/") {

      unset req.http.cookie;

      set req.grace = 15s;

    }

  }

}


sub vcl_fetch {

  if (!((req.http.Cookie ~ "member_id=" && req.http.Cookie !~ "member_id=(0|-1)") || req.http.Cookie ~ "(guestSkinChoice|language)")) {


    ## == ESI ==


    if (req.url ~ "^/(gallery/image|topic)/") {

      esi;

      unset beresp.http.set-cookie;

      set beresp.ttl = 300s;

      set beresp.grace = 30s;


    ## == Others ==


    } elseif (req.url ~ "^/(public|forum|gallery|blogs|members|user|calendar)/") {

      unset beresp.http.set-cookie;

      set beresp.ttl = 600s;

      set beresp.grace = 30s;

    }

  }

}


sub vcl_deliver {

  remove resp.http.X-Varnish;

  remove resp.http.Via;

  remove resp.http.Age;

  remove resp.http.X-Powered-By;


  if (obj.hits > 0) {

    set resp.http.X-Cache = "HIT";

  } else {

    set resp.http.X-Cache = "MISS";

  }

}

Posted

You can remove this part from the file as it's not needed.

sub vcl_deliver {


remove resp.http.X-Varnish;


remove resp.http.Via;


remove resp.http.Age;


remove resp.http.X-Powered-By;



if (obj.hits > 0) {


set resp.http.X-Cache = "HIT";


} else {


set resp.http.X-Cache = "MISS";


}


}

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...