problem about varnish-Collection of common programming errors


  • maddy
    node.js express varnish passport
    I’m a php dev, trying to understand node.js.. i can’t find the answer.. I’m making a little chat, using passport for authentication. I’ve made a facebook Strategy which works very well. I’ve made a google Strategy and i can’t figure out what’s happenning : I click on the google login, i’m redirected by google to the chat, and then i have to wait untill varnish gives me a “Error 503 Service Unavailable”.. But Node has not crashed !So varni

  • user1284857
    apache2 php varnish
    I just cannot seem to get the real client IP to show in PHP’s $_SERVER[‘REMOTE_ADDR’]. It shows in $_SERVER[‘X_FORWARDED_FOR’], but the $_SERVER[‘REMOTE_ADDR

  • Sigurs
    nginx cache varnish
    I’m trying to use Varnish to show the non-logged in users a cached version of my website. I’m able to perfectly detect if the user is logged in or out, but I can’t cache pages without extensions.There is no file extension because nginx is rewriting the URL to a php script(so caching .php does not work).For example I’d like varnish to cache: example.com example.com/forum/ example.com/contact/I have triedif (req.request == “GET” && req.url ~ “^/”) { return(lookup); } if (req.request == “GET” && req.url ~ “”) { return(lookup); } if (req.request == “GET” && req.url ~ “/”) { return(lookup); }but nothing seems to work… any help?EDIT:It still gives me X-Cache: MISS whenever I go to a extensionless page…Website is at http://www.atherys.comAnd the current VCL is…# 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”; }/* Only permit cluster to purge files from cache */ acl purge { “localhost”; }sub vcl_recv {/* Before anything else we need to fix gzip compression */if (req.http.Accept-Encoding) {if (req.url ~ “\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$”) {# No point in compressing theseremove req.http.Accept-Encoding;} else if (req.http.Accept-Encoding ~ “gzip”) {set req.http.Accept-Encoding = “gzip”;} else if (req.http.Accept-Encoding ~ “deflate”) {set req.http.Accept-Encoding = “deflate”;} else {# unknown algorithmremove req.http.Accept-Encoding;}}if (req.request == “PURGE”) {if (!client.ip ~ purge) {error 405 “Not allowed.”;}/* Always purge by URL rather than going via vcl_hashas it hashes other factors which break purging */purge_url(req.url);error 200 “Purged”;}#Remove cookies,remove queries and cache everything from content.gazamo-cdn.comif (req.http.host == “content.gazamo-cdn.com”) {remove req.http.Cookie;set req.url = regsub(req.url, “\?.*$”, “”);}#Atherys specific, if not logged in = cache; if logged in = p

  • Sukhjinder Singh
    apache2 varnish drupal
    Recently we have configured Varnish on our server, it was successfully setup but we noticed that if we open any page in multiple browsers, the Varnish send request to Apache not matter page is cached or not. If we refresh twice on each browser it creates duplicate copies of the same page.What exactly should happen: If any page is cached by Varnish, the subsequent request should be served from Varnish itself when we are opening the same page in browser OR we are opening that page from different IP address.Following is my default.vcl filebackend default {.host = “127.0.0.1”;.port = “80”; }sub vcl_recv {if( req.url ~ “^/search/.*$”){}else {set req.url = regsub(req.url, “\?.*”, “”); }if (req.restarts == 0) {if (req.http.x-forwarded-for) {set req.http.X-Forwarded-For = req.http.X-Forwarded-For + “, ” + client.ip;} else {set req.http.X-Forwarded-For = client.ip;} }if (!req.backend.healthy) {unset req.http.Cookie; }set req.grace = 6h;if (req.url ~ “^/status\.php$” ||req.url ~ “^/update\.php$” ||req.url ~ “^/admin$” ||req.

  • John Gardeniers
    varnish
    I install varnish3.03 with yum! I got a problem with it my varnish config bellow:**# #backend weibo {.host = “192.168.1.178”;.port = “8080”;.connect_timeout=20s;.first_byte_timeout=20s;.between_bytes_timeout=20s; }#backend smth {.host = “192.168.1.115”;.port = “8080”;.connect_timeout=20s;.first_byte_timeout=20s;.between_bytes_timeout=20s; }#sub vcl_recv {if (req.restarts == 0) {if (req.http.x-forwarded-for) {set req.http.X-Forwarded-For =req.http.X-Forwarded-For + “, ” + client.ip;} else {set req.http.X-Forwarded-For = client.ip;}}if (req.request != “GET” &&req.request != “HEAD” &&req.request != “PUT”

  • Thomas
    reverse-proxy cache varnish magento
    I would like to kindly ask someone for help. I browsed a lot of pages containing Varnish tutorials and sample VCL files, but I can’t find anything related to configurating Varnish for Magento (at least they don’t function right).All manuals I’ve found thrown a lot of errors during Varnish starting and it seems thay are suitable for old versions. (Also none of magento modules PageCache & Varnish Extension don’t work for me, because I think Varnish itself is not working right)My problem: 1. I get Varnish to cache front-end, but it breaks almost every functionalities of m

  • kiamlaluno
    apache2 performance reverse-proxy centos5 varnish
    I just installed and configured Varnish to work on port 80, and Apache to work on port 8080. I am trying to start Varnish with the command service varnish start, but it gave me this error:varnishd dead but pid file existsI edited this configuration in the /etc/sysconfig/varnish:DAEMON_OPTS=”-a :80 \-T localhost:6082 \-f /etc/varnish/default.vcl \-u varnish -g varnish \-S /etc/varnish/secret \-s file,/var/lib/varnish/varnish_storage.bin,1G”This is the content of the default.vcl file:backend default {.host = “127.0.0.1”;.port = “8080”;.connect_timeout = 600s;.first_byte_timeout = 600s;.between_bytes_timeout = 600s; }sub vcl_recv {if (req.request != “GET” &&req.request != “HEAD” &&req.request != “PUT” &&req.request != “POST” &&req.request != “TRACE” &&req.request != “OPTIONS” &&req.request != “DELETE”) {// Non-RFC2616 or CONNECT which is weird. return (pipe);}if (req.request != “GET” && req.request != “HEAD”) {// We only deal with GET and HEAD by defaultreturn (pass);}//

  • EApubs
    varnish
    In my server, I have varnish setup. I use wordpress and installed w3 total cache plugin. I have set that plugin to purge my varnish (varnish 3) cache. But its not working! In my syslog, there are some errors like show below… please help me!Mar 22 21:29:40 kadupul varnishd[3755]: CLI telnet 113.59.222.126 58833 77.81.240.177 6082 Rd GET / HTTP/1.1Mar 22 21:29:40 kadupul varnishd[3755]: CLI telnet 113.59.222.126 58833 77.81.240.177 6082 Wr 101 Unknown request. Type ‘help’ for more info. all comm$Mar 22 21:29:40 kadupul varnishd[3755]: CLI telnet 113.59.222.126 58833 77.81.240.177 6082 Rd Host: 77.81.240.177:6082Mar 22 21:29:40 kadupul varnishd[3755]: CLI telnet 113.59.222.126 58833 77.81.240.177 6082 Wr 101 Unknown request. Type ‘help’ for more info. all comm$Mar 22 21:29:40 kadupul varnishd[3755]: CLI telnet 113.59.222.126 58833 77.81.240.177 6082 Rd User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:11.$Mar 22 21:29:40 kadupul varnishd[3755]: CLI telnet 113.59.222.126 58833 77.81.240.177 6082 Wr 101 Unknown request. Type ‘help’ for more info. all comm$Mar 22 21:29:40 kadupul varnishd[

  • embwbam
    centos load-balancing varnish node.js
    We’re currently using Varnish because it does a good job caching, and I’m trying to get it to perform well on cache misses. My benchmarks are giving me results I don’t understand. I have 3 boxes from rackspace, all running Centos 5.5. 1 has Varnish installed (4 GB instance), the other two have a simple Hello World node applicatio

  • Alan Third
    forms pressflow cookies varnish
    We have a Pressflow 6 website behind a Varnish cache but our cache hit-rate is awfully low. I’ve recently found that stripping the “Cookie” header from requests completely increases the hit-rate to 97-98%.The vast majority of our users are anonymous, so Pres

  • M.B.Asfoor
    6 performance pressflow varnish reverse-proxy
    I just installed and configured varnish to work on port 80 and apache to work on port 8080 I’m trying to start varnish withe the command service varnish start but it gave me this error:varnishd dead but pid file existsI edited this configuration in the /etc/sysconfig/varnish:DAEMON_OPTS=”-a :80 \-T localhost:6082 \-f /etc/varnish/default.vcl \-u varnish -g varnish \-S /etc/varnish/secret \-s file,/var/lib/varnish/varnish_storage.bin,1G”And this is my varnish default.vcl file:backend default {.host = “127.0.0.1”;.port = “8080”;.connect_timeout = 600s;.first_byte_timeout = 600s;.between_bytes_timeout = 600s; }sub vcl_recv {if (req.request != “GET” &&req.request != “HEAD” &&req.request != “PUT” &&req.request != “POST” &&req.request != “TRACE” &&req.request != “OPTIONS” &&req.request != “DELETE”) {// Non-RFC2616 or CONNECT which is weird. return (pipe);}if (req.request != “GET” && req.request != “HEAD”) {// We only deal with GET and HEAD by defaultreturn (pass);}// Remove has_js and Google Analytics cookies.set req.http.Cookie = regsuball(req.http.Cookie, “(^|;\s*)(__[a-z]+|__utma_a2a|has_js)=[^;]*”, “”);// To users: if you have additional cookies being set by your system (e.g.// from a javascript analytics file or similar) you will need to add VCL// at this point to strip these cookies from the req object, otherwise// Varnish will not cache the response. This is safe for cookies that your// backend (Drupal) doesn’t process.//// Again, the common example is an analytics or other Javascript add-on.// You should do this here, before the other cookie stuff, or by adding// to the regular-expression above.// Remove a “;” prefix, if present.set req.http.Cookie = regsub(req.http.Cookie, “^;\s*”, “”);// Remove empty cookies.if (req.http.Cookie ~ “^\s*$”) {unset req.http.Cookie;}if (req.http.Authorization || req.http.Cookie) {// Not cacheable by default return (pass);}// Skip the Varnish cache for install, update, and cronif (req.url ~ “install\.php|update\.php|cron\.php”) {return (pass);}// Normalize the Accept-Encoding header// as per: http://varnish-cache.org/wiki/FAQ/Compressionif (req.http.Accept-Encoding) {if (req.url ~ “\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$”) {# No point in compressing theseremove req.http.Accept-Encoding;}elsif (req.http.Accept-Encoding ~ “gzip”) {set req.http.Accept-Encoding = “gzip”;}else {# Unknown or deflate algorithmremove req.http.Accept-Encoding;}}// Let’s have a little graceset req.grace = 30s;return (lookup); }sub vcl_hash {if (req.http.Cookie) {hash_data (req.http.Cookie);} }// Strip any cookies before an image/js/css is inserted into cache. sub vcl_fetch {if (req.url ~ “\.(png|gif|jpg|swf|css|js)$”) {// For Varnish 2.0 or earlier, replace beresp with obj:// unset obj.http.set-cookie;unset beresp.http.set-cookie;} }// Set a header to track a cache HIT/MISS. sub vcl_deliver {if (obj.hits > 0) {set resp.http.X-Varnish-Cache = “HIT”;}else {set resp.http.X-Varnish-Cache = “MISS”;} }sub vcl_error {// Let’s deliver a friendlier error page.// You can customize this as you wish.set obj.http.Content-Type = “text/html; charset=utf-8”;synthetic {“”} + obj.status + ” ” + obj.response + {“#page {width: 400px; padding: 10px; margin: 20px auto; border: 1px solid black; background-color: #FFF;}p {margin-left:20px;}body {background-color: #DDD; margin: auto;}

    Page Could Not Be Loaded

    We’re very sorry, but the page could not be loaded properly. This should be fixed very soon, and we apologize for any inconvenience.

    Debug Info:

    Status: "} + obj.status + {" Response: "} + obj.response + {" XID: "} + req.xid + {"

    “};return(deliver); }Here is apache log:[Sun Apr 22 14:27:16 2012] [error] [client 82.166.164.82] File does not exist: /var/www/html/favicon.ico [Sun Apr 22 14:27:31 2012] [error]


  • Nicholas Tolley Cottrell
    varnish varnish-vcl
    When sending a GET request directly to the backend with If-Modified-Since: Wed, 15 Feb 2012 07:25:00 CET set, Apache correctly returns a 304 with no content.When I send the same request through Varnish 3.0.2, it responds with a 200 and resends all the content even though the client already has it. Obviously, this isn’t a good use of bandwidth. My understanding is that Varnish supports intelligent handling of this header and should be sending a 304, so I figure I’d done something wrong with my .vcl file. Varnishlog gives this:16 SessionOpen c 84.97.17.233 64416 :8016 ReqStart c 84.97.17.233 64416 159732369016 RxRequest c GET16 RxURL c /fr/CS/CS_AU-Maboreke-6-6-2004.pdf16 RxProtocol c HTTP/1.016 RxHeader c Host: www.quotaproject.org16 RxHeader c User-Agent: Sprawk/1.3 (http://www.sprawk.com/)16 RxHeader c Accept: */*16 RxHeader c Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.716 RxHeader c Connection: close16 RxHeader c If-Modified-Since: Wed, 15 Feb 2012 07:25:00 CET16 VCL_call c recv lookup16 VCL_call c hash16 Hash c /fr/CS/CS_AU-Maboreke-6-6-2004.pdf16 Hash c www.quotaproject.org16 VCL_return c hash16 Hit c 159732275616 VCL_call c hit16 VCL_acl c NO_MATCH CTRLF516 VCL_return c deliver16 VCL_call c deliver deliver16 TxProtocol c HTTP/1.116 TxStatus c 20016 TxResponse c OK16 TxHeader c Server: Apache16 TxHeader c Last-Modified: Wed, 09 Jun 2004 16:07:50 GMT16 TxHeader c Vary: Accept-Encoding16 TxHeader c Content-Type: application/pdf16 TxHeader c Date: Wed, 22 Feb 2012 18:25:05 GMT16 TxHeader c Age: 1243216 TxHeader c Connection: close16 Gzip c U D – 107685 115763 80 796748 86141516 Length c 9830416 ReqEnd c 1597323690 1329935105.713264704 1329935106.208528996 0.000071526 0.000068426 0.49519586616 SessionClose c EOF mode16 StatSess c 84.97.17.233

  • hennaheto
    plone buildout varnish
    I would like to use plone.recipe.varnisin buildout to configure varnish to round-robin between 2 zeo clients. In my buildout.cfg I have tried:[varnish-build] recipe = zc.recipe.cmmi url = http://downloads.sourceforge.net/project/varnish/varnish/2.1.3/varnish-2.1.3.tar.gz[varnish-instance] recipe = plone.recipe.varnish dae

  • AbrahamSustaita
    caching varnish varnish-vcl
    I have this vcl varnish config file, but it is throwing an error when I wanto to purge from the app server. is there anything wrong on it?I have 5 app servers and everything except admin and forums are being cached, however, when I user purge from the app servers it throws this error: Failed to connect to varnishadm on 192.168.11.41:6082; “Conection rejected”backend app01 {.host = “app01.xxx.com”;.port = “80”;.connect_timeout = 0.7s;.first_byte_timeout = 30s;.between_bytes_timeout = 30s;.probe = {.url = “/”;.interval = 5s;.timeout = 1s;.window = 5;.threshold = 3;} }backend app02 {.host = “app02.xxx.com”;.port = “80”;.connect_timeout = 0.7s;.first_byte_timeout = 30s;.between_bytes_timeout = 30s;.probe = {.url = “/”;.interval = 5s;.timeout = 1s;.window = 5;.threshold = 3;} }backend app03 {.host = “app03.xxx.com”;.port = “80”;.connect_timeout = 0.7s;.first_byte_timeout = 30s;.between_bytes_timeout = 30s;.probe = {.url = “/”;.interval = 5s;.timeout = 1s;.window = 5;.threshold = 3;} }backend app04 {.host = “app04.xxx.com”;.port = “80”;.connect_timeout = 0.7s;.first_byte_timeout = 30s;.between_bytes_timeout = 30s;.probe = {.url = “/”;.interval = 5s;.timeout = 1s;.window = 5;.threshold = 3;} }backend app05 {.host = “app05.xxx.com”;.port = “80”;.connect_timeout = 0.7s;.first_byte_timeout = 30s;.between_bytes_timeout = 30s;.probe = {.url = “/”;.interval = 5s;.timeout = 1s;.window = 5;.threshold = 3;} }director app_director round-robin {{ .backend = app01; }{ .backend = app02; }{ .backend = app03; }{ .backend = app04; }{ .backend = app05; } }#acl internal { # “localhost”; # “127.0.0.1”; #}acl purge {“localhost”;”192.168.11.0″/24; }sub vcl_recv {if (req.request == “PURGE”) {if (!client.ip ~ purge) {error 4

  • Jacob
    daemon options varnish
    When using inline C with Varnish I’ve not been able to get /etc/varnish/default to be happy at start up.I’ve tested inline C with varnish for two things: GeoIP detection and Anti-Site-Scraping functions.The DAEMON_OPTS always complains even though I’m following what other seem to indicate works fine.My problem is that this command line start up works: varnishd -f /etc/varnish/varnish-default.conf -s file,/var/lib/varnish/varnish_storage.bin,512M -T 127.0.0.1:2000 -a 0.0.0.0:8080 -p ‘cc_command=exec cc -fpic -sha

Originally posted 2013-11-09 22:41:53.