Per Varnish2 o versione 3? Tra le due sono cambiate un po' di regole/sintassi.
Vito Il giorno 01 ottobre 2013 13:38, Lorenzo Maurizi - C.S.I.A. UniMC < lorenzo.maur...@unimc.it> ha scritto: > Ciao Vito,**** > > io ti metto giù la nostra, non con l'idea che sia perfetta, ma pare che > funzioni bene! Ovviamente se i gurus vedono qualcosa che non va, fatemelo > sapere!**** > > ** ** > > Cominciamo con la definizione dei backend. La nostra config è basata su > vari zeoclient, ti metto la config di un paio di loro**** > > ** ** > > backend zeo1_1 { .host = "xxxxxxxxxxx"; .port = "9673"; .probe = {**** > > .url = "/";**** > > .interval = 5s;**** > > .timeout = 1s;**** > > .window = 5;**** > > .threshold = 3;**** > > }**** > > .first_byte_timeout = 300s;**** > > }**** > > backend zeo1_2 { .host = "yyyyyyyyyy"; .port = "9674"; .probe = {**** > > .url = "/";**** > > .interval = 5s;**** > > .timeout = 1s;**** > > .window = 5;**** > > .threshold = 3;**** > > }**** > > .first_byte_timeout = 300s;**** > > }**** > > ** ** > > [……. omisssis altri backends ……….]**** > > ** ** > > director director_0 round-robin {**** > > {**** > > .backend = zeo2_1;**** > > }**** > > {**** > > .backend = zeo2_2;**** > > }**** > > }**** > > ** ** > > acl purge {**** > > "localhost";**** > > "xxxxxxxxxxxxxxx";**** > > "yyyyyyyyyyyyyyy";**** > > }**** > > ** ** > > sub vcl_recv {**** > > ** ** > > set req.backend = director_0;**** > > ** ** > > ## Controllo la presenza del cookie di autenticazione di Zope se > presente, faccio pass - quasi tutte **** > > ## le req. dovrebbero cadere qui dentro**** > > if (req.http.Cookie ~ "__ac(|_(name|password|persistent))=") {**** > > #### QUI SI POTREBBE SETTARE UN DIRECTOR DIVERSO PER L'EDITING**** > > return(pass);**** > > }**** > > ** ** > > if (req.backend.healthy) {**** > > set req.grace=30s;**** > > } else {**** > > set req.grace=600s;**** > > }**** > > if (req.request == "PURGE") {**** > > if (client.ip ~ purge) {**** > > return(lookup);**** > > }**** > > }**** > > 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" &&**** > > 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);**** > > }**** > > ## RIPORTATO DALLE REGOLE DI DEFAULT: se c'e' la authorization HTTP non > si deve fare cache**** > > if (req.http.Authenticate || req.http.Authorization) {**** > > return (pass);**** > > }**** > > **** > > **** > > ## STRATEGIE DI RIPULITURA PER FARE CACHE DI UNA SOLA PAGINA PER I VARI > BROWSER ripulitura accept-encoding alcuni **** > > ## browser indicano in ordine differente il deflate e il gzip > costringendo varnish a creare una copia di ogni pagina **** > > ## per ogni browser**** > > if (req.http.Accept-Encoding) {**** > > if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {**** > > # No point in compressing these**** > > remove req.http.Accept-Encoding;**** > > } elsif (req.http.Accept-Encoding ~ "gzip") {**** > > set req.http.Accept-Encoding = "gzip";**** > > } elsif (req.http.Accept-Encoding ~ "deflate") {**** > > set req.http.Accept-Encoding = "deflate";**** > > } else {**** > > # unkown algorithm**** > > remove req.http.Accept-Encoding;**** > > }**** > > }**** > > ## Rimozione Header di Accept Language: non viene usato da Zope**** > > remove req.http.Accept-Language;**** > > ## Ripulitura cookie google analytics serve ad evitare la generazione > di pagine doppie per la presenza dei cookie di **** > > ## google analytics**** > > set req.http.Cookie = > regsuball(req.http.Cookie,"(^|;\s*)(__utm[a-z])=[^;]+;??", "");**** > > set req.http.Cookie = regsuball(req.http.Cookie,"(^|;\s*);","");**** > > set req.http.Cookie = regsuball(req.http.Cookie,";\s*;",";");**** > > **** > > ## ripulitura finale cookies: se rimane riga vuota o spazi bianchi, si > fa remove dell'header**** > > if (req.http.Cookie == "" || req.http.cookie ~ "^\s*$") {**** > > remove req.http.Cookie;**** > > }**** > > ** ** > > ## Controllo la presenza del cookie di autenticazione di Zope se non > presente, faccio LOOKUP quasi tutte le req. **** > > ## dovrebbero cadere qui dentro**** > > if (!(req.http.Cookie ~ "__ac(|_(name|password|persistent))=")) {**** > > return(lookup);**** > > }**** > > ** ** > > ## Se a questo punto ho ancora cookie (dovrebbe essere solo quello di > autenticazione di Zope) faccio PASS**** > > if (req.http.Cookie) {**** > > return (pass);**** > > }**** > > **** > > ## DA QUI IN POI LE REGOLE DI DEFAULT gia' considerate sopra**** > > if (req.http.Authorization || req.http.Cookie) {**** > > #Not cacheable by default**** > > #### QUI SI POTREBBE SETTARE UN DIRECTOR DIVERSO PER L'EDITING COME > SOPRA**** > > return (pass);**** > > }**** > > ## il default finale se tutto viene saltato e' il LOOKUP**** > > return (lookup);**** > > }**** > > ** ** > > sub vcl_hit {**** > > if (req.request == "PURGE") {**** > > set obj.ttl = 0s;**** > > error 200 "Purged.";**** > > }**** > > }**** > > sub vcl_miss {**** > > if (req.request == "PURGE") {**** > > error 404 "Not in cache.";**** > > }**** > > }**** > > ** ** > > ** ** > > ** ** > > ** ** > > ** ** > ------------------------------ > > *Ing. Lorenzo Maurizi -* Ufficio Web, Comunicazione, Sviluppo & Ricerca*** > * > > *Università degli Studi di Macerata ***** > > C.S.I.A. - Centro di Servizio per l'Informatica d'Ateneo **** > > *Vicolo Tornabuoni, 58 - 62100 Macerata > Tel +39 0733 258 4406 - Fax +39 0733 258 4415 > http://www.unimc.it <http://celfi.unimc.it>***** > > ** ** > > P* non stampare questa mail, se non è necessario* > > * * > > *Informativa Privacy* - Ai sensi del D. Lgs n. 196/2003 (Codice Privacy) > si precisa che le informazioni contenute in questo messaggio sono riservate > e ad uso esclusivo del destinatario. Qualora il messaggio in parola Le > fosse pervenuto per errore, La preghiamo di eliminarlo senza copiarlo e di > non inoltrarlo a terzi, dandocene gentilmente comunicazione. Grazie. **** > > *Privacy Information* - This message, for the D. Lgs n. 196/2003 (Privacy > Code), may contain confidential and/or privileged information. If you are > not the addressee or authorized to receive this for the addressee, you must > not use, copy, disclose or take any action based on this message or any > information herein. If you have received this message in error, please > advise the sender immediately by reply e-mail and delete this message. Thank > you for your cooperation.**** > > ** ** > > *Da:* plone-plone-it-boun...@lists.plone.org [mailto: > plone-plone-it-boun...@lists.plone.org] *Per conto di *Vito Falco > *Inviato:* martedì 1 ottobre 2013 12:51 > *A:* La lista degli italiani appassionati di Plone. > *Oggetto:* [Plone-IT] La "vcl" perfetta per Varnish & Plone esiste?**** > > ** ** > > Ciao,**** > > come sempre, quando mi confronto con la parte "sistemistica" del nostro > CMS preferito, entro un po' in crisi.**** > > ** ** > > Ho un server Ubuntu così configurato**** > > Varnish > Nginx > Zeo**** > > ** ** > > Varnish: solo cache sulla 80**** > > Nginx: rewrite e gestione di pagine statiche**** > > ** ** > > Varnish v.3 è configurato in maniera "standard" e non mi da > soddisfazione, oltre a fare un po' di casini e costringere l'utente a fare > refresh forzoso.**** > > ** ** > > Qualcuno vuol condividere una "vcl" perfetta (o quasi)? > Thank's**** > > Vito > **** > > ** ** > > -- **** > > *Vito Falco* > Webdeveloper & designer freelance, Plone enthusiast **** > > Bari, IT**** > > tel +39 3346330137 | skype vito80ba | twitter vito80ba**** > > Linkedin http://it.linkedin.com/in/vitof**** > > _______________________________________________ > Plone-IT mailing list > plone...@lists.plone.org > https://lists.plone.org/mailman/listinfo/plone-plone-it > http://plone-regional-forums.221720.n2.nabble.com/Plone-Italy-f221721.html > -- *Vito Falco* Webdeveloper & designer freelance, Plone enthusiast Bari, IT tel +39 3346330137 | skype vito80ba | twitter vito80ba Linkedin http://it.linkedin.com/in/vitof
_______________________________________________ Plone-IT mailing list plone...@lists.plone.org https://lists.plone.org/mailman/listinfo/plone-plone-it http://plone-regional-forums.221720.n2.nabble.com/Plone-Italy-f221721.html