•
Eliminar headers que añade varnish
En el caso que tengamos sirviendo una cierta web a través de un varnish, veremos que nos añade ciertos headers que hacen visible esta información:
$ curl -I systemadmin.es HTTP/1.1 200 OK Server: Apache P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM" Content-Type: text/html;charset=utf-8 Vary: Accept-Encoding dheader: fetch Content-Length: 28049 Date: Fri, 06 Jul 2012 06:57:33 GMT X-Varnish: 1440901304 1440890669 Age: 586 Via: 1.1 varnish Connection: keep-alive
Estos headers se añaden automáticamente y no hay una opción para desactivarlos a no ser que modifiquemos el código fuente:
http_SetHeader(sp->wrk, sp->fd, sp->wrk->resp, "Via: 1.1 varnish");
Pero en el vcl_deliver podemos eliminar los headers (después de haber sido añadidos), por ejemplo para quitar el Via haríamos:
(...) sub vcl_deliver { remove resp.http.Via; return (deliver); } (...)
Si vemos los headers de la respuesta con curl vemos como ha desaparecido dicho headers:
$ curl -I systemadmin.es HTTP/1.1 200 OK Server: Apache Set-Cookie: CAKEPHP=d7451d1587779d6cc937b2d0ffdc7062; expires=Sat, 14-Jul-2012 15:13:49 GMT; path=/ P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM" Content-Type: text/html;charset=utf-8 Vary: Accept-Encoding Content-Length: 27983 Date: Fri, 06 Jul 2012 07:13:49 GMT X-Varnish: 1455575548 Age: 0 Connection: keep-alive
Podemos eliminar también el X-Varnish y el Age con:
sub vcl_deliver { remove resp.http.Via; remove resp.http.X-Varnish; remove resp.http.Age; return (deliver); }
Siendo el resultado igual que si no hubiéramos instalado el varnish:
$ curl -I systemadmin.es HTTP/1.1 200 OK Server: Apache Set-Cookie: CAKEPHP=c55a4748a35dad630806269709bd846c; expires=Sat, 14-Jul-2012 15:45:06 GMT; path=/ P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM" Content-Type: text/html;charset=utf-8 Vary: Accept-Encoding Content-Length: 28021 Date: Fri, 06 Jul 2012 07:45:06 GMT Connection: keep-alive
Deja un comentario: