Varnish?


Status
Not open for further replies.
coba disable dulu aja yang dikira jadi kendala .. terlalu sering trouble tidak baik bagi mesin produksi :)

salam,
 
klo mas galuh apa sama juga nemu masalah seperti itu ?

apache+varnish+nginx baru saya coba di vps tempat ngoprek .. sejauh ini aplikasi wp, drupal dan joomla normal2 saja .. proses upload di wp juga normal tapi baru saya coba untuk file image kisaran 500KB
 
coba disable dulu aja yang dikira jadi kendala .. terlalu sering trouble tidak baik bagi mesin produksi :)

salam,
trouble nya itu file upload saja... sedangkan lainnya jalan... yang jadi masalah itu sewaktu nginx nya membaca response header dari varnish nya malah connection reset by peer.. untuk file dibawah 25 kb fine fine aja... ini yang jadi masalah.. kemarin bisa di gedein itu buffernya.. eh malah error lagi...
 
masalah solved... dicoba upload 3 mb tidak ada masalah.. sepertinya script unixy nya yang error... ada konfigurasi yang membatasi sepertinya di varnish nya... ok.. masalah terselesaikan.. :D.. pakai default.vcl asalnya varnish..

Code:
backend default {
  .host = "127.0.0.1";
  .port = "82";
}
#
#Below is a commented-out copy of the default VCL logic.  If you
#redefine any of these subroutines, the built-in logic will be
#appended to your code.
#
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 default */
        return (pass);
    }
    if (req.http.Authorization || req.http.Cookie) {
        /* Not cacheable by default */
        return (pass);
    }
    return (lookup);
}

entah yang pakai scriptnya unixy ada masalah apa tidak, soalnya pakai itu juga sama persis error... tidak bisa upload file.. =_=
 
Ini versi yang udah fix.. mirip dengan script unixy tetapi tidak ada masalah dalam hal upload file..

Code:
#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 = "_diisi dengan ip_";
  .port = "_diisi port backend_";
}

#Below is a commented-out copy of the default VCL logic.  If you
#redefine any of these subroutines, the built-in logic will be
#appended to your code.

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 default */
        return (pass);
    }
    if (req.http.Authorization || req.http.Cookie) {
        /* Not cacheable by default */
        return (pass);
    }
    return (lookup);
}

sub vcl_fetch {

set beresp.ttl = 600s;
set beresp.http.Server = "Apache/2.2.19";

# Turn off Varnish gzip processing
set beresp.do_gzip = false;
set beresp.do_gunzip = false;
set beresp.do_stream = false;
set beresp.do_esi = false;

# Grace to allow varnish to serve content if backend is lagged
set beresp.grace = 5 m;

# Restart rule bfile for fetch
if ( beresp.http.Content-Length ~ "[0-9]{8,}" ) {
        set req.http.x-pipe = "1";
        return (restart);
}

# These status codes should always pass through and never cache.
if (beresp.status == 503 || beresp.status == 500) {
        set beresp.http.X-Cacheable = "NO: beresp.status";
        set beresp.http.X-Cacheable-status = beresp.status;
        return (hit_for_pass);
}

if (beresp.status == 404) {
        set beresp.http.magicmarker = "1";
        set beresp.http.X-Cacheable = "YES";
        set beresp.ttl = 20 s;
        return (deliver);
}

/* Remove Expires from backend, it's not long enough */
unset beresp.http.expires;

if (req.url ~ "\.(js|css|jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|pdf|ico)$" && ! (req.url ~ "\.(php)") ) 
{
        unset beresp.http.set-cookie;
        set beresp.ttl = 20 m;
}
else {
        set beresp.ttl = 5 m;
}

/* marker for vcl_deliver to reset Age: */
set beresp.http.magicmarker = "1";

# All tests passed, therefore item is cacheable
set beresp.http.X-Cacheable = "YES";

return (deliver);
}


sub vcl_deliver {

  # From http://varnish-cache.org/wiki/VCLExampleLongerCaching
  if (resp.http.magicmarker) {
     /* Remove the magic marker */
     unset resp.http.magicmarker;

     /* By definition we have a fresh object */
     set resp.http.age = "0";
   }

   #add cache hit data
   if (obj.hits > 0) {
     #if hit add hit count
     set resp.http.X-Cache = "HIT";
     set resp.http.X-Cache-Hits = obj.hits;
   }
else {
     set resp.http.X-Cache = "MISS";
   }

}

sub vcl_hit {

if (obj.ttl < 1s) {
        return (pass);
}

if (req.http.Cache-Control ~ "no-cache") {
# Ignore requests via proxy caches,  IE users and badly behaved crawlers
# like msnbot that send no-cache with every request.
if (! (req.http.Via || req.http.User-Agent ~ "bot|MSIE|HostTracker")) {
        set obj.ttl = 0s;
        return (restart);
}
}

return (deliver);

}

sub vcl_error {

if (obj.status == 503 && req.restarts < 5) {
set obj.http.X-Restarts = req.restarts;
return (restart);
}

}

sub vcl_pipe {
    set bereq.http.connection = "close";

    if (req.http.X-Forwarded-For) {
        set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;
    } else {
        set bereq.http.X-Forwarded-For = regsub(client.ip, ":.*", "");
    }
}

sub vcl_pass {
    set bereq.http.connection = "close";

    if (req.http.X-Forwarded-For) {
        set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;
    } else {
        set bereq.http.X-Forwarded-For = regsub(client.ip, ":.*", "");
    }
}

Hasil headernya script diatas.

Code:
HTTP/1.1 200 OK =>
Server => nginx/1.0.4
Date => Sat, 23 Jul 2011 05:07:18 GMT
Content-Type => text/html; charset=UTF-8
Connection => close
X-Pingback => http://tokohosting.biz/xmlrpc.php
X-Powered-By => W3 Total Cache/0.9.2.3
Vary => Accept-Encoding,User-Agent
X-Cacheable => YES
Content-Length => 18326
Accept-Ranges => bytes
X-Varnish => 1715052024 1715052023
Via => 1.1 varnish
age => 0
X-Cache => HIT
X-Cache-Hits => 1

Bug nya masih belum nemu lagi.. tapi upload file 3 MB udah no problem.. :) wordpress, joomla, dan cms lainnya udah jalan normal.. tidak ada kendala.. entah untuk masalah looping waktu erase thread varnishnya.. masih kejadian atau tidak..
 
Status
Not open for further replies.
Back
Top