download do arquivo de verniz falha da sessão do usuário

1

Eu tenho 2 servidores 3.0.4 de verniz na borda de um cluster Apache (diretor de fallback). Em um dos meus sites, os usuários fazem login para baixar conteúdo estático, como pdf, imagens (jpg, jpeg, png, gif), xls / xlsx, etc. Todos os arquivos exel são informados para serem armazenados em cache.

Ao baixar um arquivo do Excel, tudo funciona conforme o esperado. Ao tentar baixar um objeto em cache, o comportamento é diferente. Mesmo que o site seja exibido corretamente (todas as imagens aparecem), o usuário é desconectado e o arquivo não pode ser buscado (404 de vernizlog). Nenhum problema ao navegar no site quando conectado.

Usando o arquivo host para apontar diretamente no Apache e o download dos arquivos perfeitamente.

Como uma solução temporária disse ao verniz para não armazenar em cache para este site e proibiu todo o conteúdo para ele.

Obrigado.

EDIT: vcl completo e vernizlog.

Obrigado pela sua ajuda. Infelizmente ainda não está funcionando. Aqui está minha vlc completa

backend srv1 {
        .host = "srv1";
        .port = "80";
        .first_byte_timeout = 120s;
        .probe = {
                .url = "/";
                .interval = 5s;
                .timeout = 1s;
                .window = 5;
                .threshold = 3;
        }
}

backend srv2 {
        .host = "srv2";
        .port = "80";
        .first_byte_timeout = 120s;
        .probe = {
                .url = "/";
                .interval = 5s;
                .timeout = 1s;
                .window = 5;
                .threshold = 3;
        }
}

backend srv3 {
        .host = "srv3";
        .port = "80";
        .first_byte_timeout = 120s;
        .probe = {
                .url = "/";
                .interval = 5s;
                .timeout = 1s;
                .window = 5;
                .threshold = 3;
        }
}

director cluster fallback {
        { .backend = srv1; }
        { .backend = srv2; }
        { .backend = srv3; }
}

sub vcl_recv {
        set req.backend = cluster;

        if (req.url ~ "\.(htm|html|xml|jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|pdf|flv|swf)$") {
        return (lookup);
        }

        if (req.http.Authorization || req.http.Cookie) {
        return (pass);
        }

        # Normalize encoding/compression
        if (req.http.Accept-Encoding) {
        if (req.http.Accept-Encoding ~ "gzip") { set req.http.Accept-Encoding = "gzip";     }
        elsif (req.http.Accept-Encoding ~ "deflate") { set req.http.Accept-Encoding = "deflate"; }
        else { remove req.http.Accept-Encoding; }
        }

        if (req.request == "PURGE") {
        if (!client.ip ~ purge) {
                error 405 "Not allowed.";
        }
        return (lookup);
        }
}

acl purge {
        "localhost";
}

#
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.";
        }
}

sub vcl_fetch {
if (req.url ~ "\.(htm|html|xml|jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|pdf|flv|swf)$") {
        return (deliver);
        }
}
sub vcl_deliver {
        if (obj.hits > 0)
                { set resp.http.X-Cache = "HIT from Varnish"; }
        else
                { set resp.http.X-Cache = "MISS from Varnish"; }
}

E aqui está o rastreio completo do verniz ao tentar baixar um arquivo:

   50 BackendOpen  b srv1 10.24.1.11 40049 10.24.1.95 80
   50 TxRequest    b GET
   50 TxURL        b /de-ge/content/download/992186/17973237/version/1/file/PB_CAN_EDUC_Trockennahrung.pdf
   50 TxProtocol   b HTTP/1.1
   50 TxHeader     b Via: 1.1 ClientSiteProxy:3128 (squid/2.7.STABLE4), 1.0 proxy-1_5 (squid/3.1.19), 1.1 cache-3:80, 1.0 SPRX0008
   50 TxHeader     b Host: mysite.domain.com
   50 TxHeader     b Referer: http://mysite.domain.com/de-ge/website-material/vet_basic/produktdatenblaetter
   50 TxHeader     b User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
   50 TxHeader     b Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
   50 TxHeader     b Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
   50 TxHeader     b X-Teacup: eFDRDF7Vx0755xk=
   50 TxHeader     b X-Forwarded-For: CLIENT_IP, PUBLIC_IP
   50 TxHeader     b X-Varnish: 1630421623
   50 TxHeader     b Accept-Encoding: gzip
   50 RxProtocol   b HTTP/1.1
   50 RxStatus     b 404
   50 RxResponse   b Not Found
   50 RxHeader     b Date: Wed, 08 Jan 2014 10:02:24 GMT
   50 RxHeader     b Server: Apache
   50 RxHeader     b Expires: Thu, 19 Nov 1981 08:52:00 GMT
   50 RxHeader     b Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, public, no-transform
   50 RxHeader     b Pragma: no-cache
   50 RxHeader     b X-Powered-By: eZ Publish
   50 RxHeader     b Served-by: mysite.domain.com
   50 RxHeader     b Content-language: de-DE
   50 RxHeader     b Set-Cookie: PHPSESSID=ob5a4jaic2ubpvala2qacksl17; path=/
   50 RxHeader     b Content-Length: 7030
   50 RxHeader     b Connection: close
   50 RxHeader     b Content-Type: text/html; charset=utf-8
   50 Fetch_Body   b 4(length) cls 0 mklen 1
   50 Length       b 7030
   50 BackendClose b srv1
   24 ReqStart     c REVERSE_PROXY_IP(NOT VARNISH) 57364 1630421623
   24 RxRequest    c GET
   24 RxURL        c /de-ge/content/download/992186/17973237/version/1/file/PB_CAN_EDUC_Trockennahrung.pdf
   24 RxProtocol   c HTTP/1.1
   24 RxHeader     c Via: 1.1 ClientSiteProxy:3128 (squid/2.7.STABLE4), 1.0 proxy-1_5 (squid/3.1.19), 1.1 cache-3:80, 1.0 SPRX0008
   24 RxHeader     c Host: mysite.domain.com
   24 RxHeader     c Cookie: ISAWPLB{515B9AC4-0CEE-4B2B-B32F-DB0AD870EC2F}={DF5E7FFB-0F55-466C-9DDC-2983CFDF75AE}; PHPSESSID=nfcqe0tcq7gqiu253ef3o9svu4; is_logged_in=true
   24 RxHeader     c Referer: http://mysite.domain.com/de-ge/website-material/vet_basic/produktdatenblaetter
   24 RxHeader     c User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
   24 RxHeader     c Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
   24 RxHeader     c Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
   24 RxHeader     c X-Teacup: eFDRDF7Vx0755xk=
   24 RxHeader     c X-Forwarded-For: CLIENT_IP, PUBLIC_IP
   24 RxHeader     c Cache-Control: max-age=259200
   24 RxHeader     c Connection: Keep-Alive
   24 VCL_call     c recv lookup
   24 VCL_call     c hash
   24 Hash         c /de-ge/content/download/992186/17973237/version/1/file/PB_CAN_EDUC_Trockennahrung.pdf
   24 Hash         c mysite.domain.com
   24 VCL_return   c hash
   24 VCL_call     c miss fetch
   24 Backend      c 50 cluster srv1
   24 TTL          c 1630421623 RFC 0 -1 -1 1389175345 0 1389175344 375007920 0
   24 VCL_call     c fetch deliver
   24 ObjProtocol  c HTTP/1.1
   24 ObjResponse  c Not Found
   24 ObjHeader    c Date: Wed, 08 Jan 2014 10:02:24 GMT
   24 ObjHeader    c Server: Apache
   24 ObjHeader    c Expires: Thu, 19 Nov 1981 08:52:00 GMT
   24 ObjHeader    c Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, public, no-transform
   24 ObjHeader    c Pragma: no-cache
   24 ObjHeader    c X-Powered-By: eZ Publish
   24 ObjHeader    c Served-by: mysite.domain.com
   24 ObjHeader    c Content-language: de-DE
   24 ObjHeader    c Set-Cookie: PHPSESSID=ob5a4jaic2ubpvala2qacksl17; path=/
   24 ObjHeader    c Content-Type: text/html; charset=utf-8
   24 VCL_call     c deliver deliver
   24 TxProtocol   c HTTP/1.1
   24 TxStatus     c 404
   24 TxResponse   c Not Found
   24 TxHeader     c Server: Apache
   24 TxHeader     c Expires: Thu, 19 Nov 1981 08:52:00 GMT
   24 TxHeader     c Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, public, no-transform
   24 TxHeader     c Pragma: no-cache
   24 TxHeader     c X-Powered-By: eZ Publish
   24 TxHeader     c Served-by: mysite.domain.com
   24 TxHeader     c Content-language: de-DE
   24 TxHeader     c Set-Cookie: PHPSESSID=ob5a4jaic2ubpvala2qacksl17; path=/
   24 TxHeader     c Content-Type: text/html; charset=utf-8
   24 TxHeader     c Content-Length: 7030
   24 TxHeader     c Accept-Ranges: bytes
   24 TxHeader     c Date: Wed, 08 Jan 2014 10:02:25 GMT
   24 TxHeader     c X-Varnish: 1630421623
   24 TxHeader     c Age: 0
   24 TxHeader     c Via: 1.1 varnish
   24 TxHeader     c Connection: keep-alive
   24 TxHeader     c X-Cache: MISS from Varnish
   24 Length       c 7030
   24 ReqEnd       c 1630421623 1389175344.435734510 1389175345.230693817 2.376755714 0.794904470 0.000054836

EDIT2: Não consigo usar o curl porque preciso estar logado no aplicativo. Mas tenho 200% de certeza de que o recurso está disponível desde quando eu uso meu arquivo host para acessar o servidor web, eu posso baixar os arquivos.

Veja a saída das ferramentas do Chrome:

    Request URL:http://mysite.domain.com/de-ge/content/download/1004658/18185577/version/2/file/RC_PB_CHN_Junior.pdf
    Request Method:GET
    Status Code:200 OK

    Request Headers
    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
    Connection:keep-alive
    Cookie:__utma=65825073.183772452.1389198084.1389262355.1389265715.3; __utmc=65825073; __utmz=65825073.1389198084.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); PHPSESSID=3jr13d7cqmn0kv86iho4n030i0; is_logged_in=true
    Host:mysite.domain.com
    Referer:http://mysite.domain.com/de-ge/website-material/retail_basic/produktdatenblaetter
    User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36


  Response Headers
    Accept-Ranges:bytes
    Cache-Control:public
    Connection:close
    Content-Disposition:attachment
    Content-language:de-DE
    Content-Transfer-Encoding:binary
    Content-Type:application/pdf
    Date:Thu, 09 Jan 2014 14:36:30 GMT
    Expires:Thu, 09 Jan 2014 14:46:30 GMT
    Pragma:
    Served-by:mysite.domain.com
    Server:Apache
    Transfer-Encoding:chunked
    X-Powered-By:eZ Publish

EDIT 3: Eu não consigo fazer isso funcionar. Eu e eu realmente não entendo porque todas as imagens são exibidas corretamente na zona do usuário enquanto o download de imagens (literalmente, com um prompt de download) ou outro recurso falhou.

Obrigado.

    
por frenchviking 07.01.2014 / 10:52

1 resposta

1

Suspeito que o seu back-end está sobrescrevendo o cookie, por isso vou tentar alterar vcl_fetch para:

sub vcl_fetch {
  if (req.url ~ "\.(htm|html|xml|jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|pdf|flv|swf)$") {
    unset beresp.http.set-cookie;
    return (deliver);
  }
}

De qualquer forma, é difícil dizer sem ter um rastreio de varnishlog e sua configuração vcl completa.

Depois de ver sua VCL completa e o rastreio de verniz, fica claro que o back-end está respondendo a um status 404.

Então, tente enviar uma chamada curl para o back-end para inspecionar a resposta, como:

curl -I -H "Host: mysite.domain.com" srv1/de-ge/content/download/992186/17973237/version/1/file/PB_CAN_EDUC_Trockennahrung.pdf

Depois de ver seu EDIT2:

Se você precisa estar logado para obter o recurso e os logins são baseados em cookies, está falhando porque você está removendo os cookies:

if (req.url ~ "\.(htm|html|xml|jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|pdf|flv|swf)$") {
  return (lookup);
}

BTW: você pode emitir chamadas curl com cookies:

curl -I -b "PHPSESSID=3jr13d7cqmn0kv86iho4n030i0; is_logged_in=true" -H "Host: mysite.domain.com" srv1/de-ge/content/download/992186/17973237/version/1/file/PB_CAN_EDUC_Trockennahrung.pdf
    
por 08.01.2014 / 01:20