<div dir="ltr">Hi, Miguel!<div><br></div><div>Thanks for sharing the solution. </div><div>Im not working with varnish a long time. So, i forgot this simple trick to solve the problem.</div><div><br></div><div>The setup are varnish + nginx + fpm.</div><div><br></div><div>Thanks!</div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><table style="border-collapse:collapse;border-spacing:0px;font-family:Georgia,'Times New Roman',Times,serif"><tbody><tr><td style="padding:0px 16px 0px 0px;vertical-align:top"><img src="http://up2it.com.br/assinatura/images/ds.png" style="border:0px;vertical-align:middle"></td><td style="padding:0px 0px 0px 8px;vertical-align:top;border-left-width:3px;border-left-style:solid;border-color:rgb(30,144,255)"><span><span style="font-size:13px;font-family:arial;font-weight:bold">Fabio Fraga Machado</span></span><div style="padding:2px 0px 0px"><div><span style="color:rgb(30,144,255);font-size:11px;font-family:arial;font-weight:bold">phone:</span> <span style="font-size:11px;font-family:arial"><a href="http://up2it.com.br/assinatura/tel//4840528300" style="color:rgb(0,0,0);text-decoration:none;background-color:transparent" target="_blank">(48) 4052-8300</a></span></div><div><span style="color:rgb(30,144,255);font-size:11px;font-family:arial;font-weight:bold">web:</span> <span style="font-size:11px;font-family:arial"><a href="http://www.dataspace.com.br/" style="color:rgb(0,0,0);text-decoration:none;background-color:transparent" target="_blank">www.dataspace.com.br</a></span></div><div><span style="color:rgb(30,144,255);font-size:11px;font-family:arial;font-weight:bold">email:</span> <span style="font-size:11px;font-family:arial"><a href="mailto:fabio@dataspace.com.br" style="color:rgb(0,0,0);text-decoration:none;background-color:transparent" target="_blank">fabio@dataspace.com.br</a></span></div><div><span style="color:rgb(30,144,255);font-size:11px;font-family:arial;font-weight:bold">skype:</span> <span style="font-size:11px;font-family:arial"><a style="color:rgb(0,0,0);text-decoration:none;background-color:transparent">boinkbr</a></span></div></div><div style="padding:3px 0px 0px"><a href="https://facebook.com/dataspace.brasil" style="color:rgb(69,130,236);text-decoration:none;background-color:transparent" target="_blank"><img src="http://up2it.com.br/assinatura/images/f.png" style="border:0px;vertical-align:middle;width:18px;height:18px;margin:2px"> </a><a href="https://twitter.com/data_space" style="color:rgb(69,130,236);text-decoration:none;background-color:transparent" target="_blank"><img src="http://up2it.com.br/assinatura/images/t.png" style="border:0px;vertical-align:middle;width:18px;height:18px;margin:2px"></a></div></td></tr></tbody></table><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Mon, Apr 3, 2017 at 3:47 PM, Miguel González <span dir="ltr"><<a href="mailto:miguel_3_gonzalez@yahoo.es" target="_blank">miguel_3_gonzalez@yahoo.es</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Not sure about Varnish 3.0 syntax but you need to return a pass in<br>
vcl_recv for wp-admin and other woocommerce sections (if you have<br>
woocommerce):<br>
<br>
        # --- WordPress specific configuration<br>
        # Did not cache the admin and login pages<br>
        if (req.url ~<br>
"nocache|cart|my-account|<wbr>checkout|addons|tienda|mi-<wbr>cuenta|carro|producto/*|login|<wbr>wp-admin|wp-(comments-post|<wbr>login|signup|activate|mail|<wbr>cron)\.php|preview\=true|<wbr>admin-ajax\.php|xmlrpc\.php|<wbr>bb-admin|whm-server-status|<wbr>server-status|control\.php|bb-<wbr>login\.php|bb-reset-password\.<wbr>php|register\.php")<br>
{<br>
            return (pass);<br>
        }<br>
<br>
<br>
Not sure I have understood, those two extra sites run in the same Apache<br>
server? Why don´t you use virtualhosts instead of port virtualhosts? I<br>
run Varnish in front of 40 sites run by Apache without needing to<br>
specify different backends (just one).<br>
<br>
Regards,<br>
<br>
Miguel<br>
<span class=""><br>
<br>
<br>
On 04/03/17 3:51 AM, Fabio Fraga [DS] wrote:<br>
> Hey, folks.<br>
><br>
> I have a setup on CentOS 6.8 server with 1 single ip address and<br>
> including Varnish + Nginx + php-fpm. Php works on 7.0 version.<br>
><br>
> My customer had a single website and the setup works fine so far. But he<br>
> ask to include a two new websites. My headache starts here.<br>
><br>
> When i set the backends pointing to hostname and port (in nginx),<br>
> varnish redirects to the first site. But, when i set the sub vcl_recv<br>
> correctly (using regexp), i get the correct websites.<br>
> My issue is on wp-admin. I can post text content, but i cant post images<br>
> (got http error on wordpress).<br>
> But if i remove the configuration of new backends, all things works fine.<br>
><br>
> Where am i going wrong?<br>
><br>
> Below my default.vcl.<br>
><br>
> ==============================<wbr>=<br>
><br>
> backend default {<br>
><br>
>         .host = “w.x.y.z”;<br>
><br>
>         .port = "8081";<br>
><br>
>         .connect_timeout = 60s;<br>
><br>
>         .first_byte_timeout = 60s;<br>
><br>
>         .between_bytes_timeout = 60s;<br>
><br>
>      }<br>
><br>
> backend bk1 {<br>
><br>
</span>>         .host = “<a href="http://xyz.com.br" rel="noreferrer" target="_blank">xyz.com.br</a> <<a href="http://xyz.com.br" rel="noreferrer" target="_blank">http://xyz.com.br</a>>";<br>
<span class="">><br>
>         .port = "8081";<br>
><br>
>         .connect_timeout = 60s;<br>
><br>
>         .first_byte_timeout = 60s;<br>
><br>
>         .between_bytes_timeout = 60s;<br>
><br>
>      }<br>
><br>
> backend bk2 {<br>
><br>
</span>>         .host = “<a href="http://abc.com.br" rel="noreferrer" target="_blank">abc.com.br</a> <<a href="http://abc.com.br" rel="noreferrer" target="_blank">http://abc.com.br</a>>";<br>
<span class="">><br>
>         .port = "8084";<br>
><br>
>         .connect_timeout = 60s;<br>
><br>
>         .first_byte_timeout = 60s;<br>
><br>
>         .between_bytes_timeout = 60s;<br>
><br>
>      }<br>
><br>
> backend bk3 {<br>
><br>
</span>>         .host = “<a href="http://def.com.br" rel="noreferrer" target="_blank">def.com.br</a> <<a href="http://def.com.br" rel="noreferrer" target="_blank">http://def.com.br</a>>";<br>
<div><div class="h5">><br>
>         .port = "8083";<br>
><br>
>         .connect_timeout = 60s;<br>
><br>
>         .first_byte_timeout = 60s;<br>
><br>
>         .between_bytes_timeout = 60s;<br>
><br>
>      }<br>
><br>
> acl purge {<br>
><br>
>   "localhost";<br>
><br>
>   "127.0.0.1";<br>
><br>
>   "w.x.y.z";<br>
><br>
> }<br>
><br>
><br>
> sub vcl_recv {<br>
><br>
><br>
>   if (req.http.host ~ "^(www\.)?xyz\.com\.br$") {<br>
><br>
>         set req.backend = bk1;<br>
><br>
>         return (lookup);<br>
><br>
>    }<br>
><br>
>   if (req.http.host ~ "^(www\.)?abc\.com\.br$") {<br>
><br>
>         set req.backend = bk2;<br>
><br>
>         return (lookup);<br>
><br>
>    }<br>
><br>
>   if (req.http.host ~ "^(www\.)?def\.com\.br$") {<br>
><br>
>         set req.backend = bk3;<br>
><br>
>         return (lookup);<br>
><br>
>    }<br>
><br>
><br>
>   if (req.restarts == 0) {<br>
><br>
>     if (req.http.x-forwarded-for) {<br>
><br>
>       set req.http.X-Forwarded-For =<br>
><br>
>       req.http.X-Forwarded-For + ", " + client.ip;<br>
><br>
>     } else {<br>
><br>
>       set req.http.X-Forwarded-For = client.ip;<br>
><br>
>     }<br>
><br>
>   }<br>
><br>
><br>
>   if (req.http.Accept-Encoding) {<br>
><br>
>     if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|<wbr>bz2|tbz|mp3|ogg)$") {<br>
><br>
>       # No point in compressing these<br>
><br>
>       remove req.http.Accept-Encoding;<br>
><br>
>     } elsif (req.http.Accept-Encoding ~ "gzip") {<br>
><br>
>       set req.http.Accept-Encoding = "gzip";<br>
><br>
>     } elsif (req.http.Accept-Encoding ~ "deflate") {<br>
><br>
>       set req.http.Accept-Encoding = "deflate";<br>
><br>
>     } else {<br>
><br>
>       # unknown algorithm<br>
><br>
>       remove req.http.Accept-Encoding;<br>
><br>
>     }<br>
><br>
>   }<br>
><br>
><br>
>   if (req.request == "PURGE") {<br>
><br>
>     if ( !client.ip ~ purge ) {<br>
><br>
>       error 405 "Not allowed.";<br>
><br>
>     }<br>
><br>
>     return (lookup);<br>
><br>
>   }<br>
><br>
><br>
>   if (req.request != "GET" &&<br>
><br>
>     req.request != "HEAD" &&<br>
><br>
>     req.request != "PUT" &&<br>
><br>
>     req.request != "POST" &&<br>
><br>
>     req.request != "TRACE" &&<br>
><br>
>     req.request != "OPTIONS" &&<br>
><br>
>     req.request != "DELETE") {<br>
><br>
>       return (pipe);<br>
><br>
>   }<br>
><br>
><br>
>   if (req.request != "GET" && req.request != "HEAD") {<br>
><br>
>     return (pass);<br>
><br>
>   }<br>
><br>
><br>
>   if ( req.http.cookie ~ "wordpress_logged_in" ) {<br>
><br>
>     return(pass);<br>
><br>
>   }<br>
><br>
><br>
>   if (<br>
><br>
>     !(req.url ~ "wp-(login|admin)")<br>
><br>
>     && !(req.url ~ "&preview=true" )<br>
><br>
>   ){<br>
><br>
>     unset req.http.cookie;<br>
><br>
>   }<br>
><br>
><br>
>   if (req.http.Authorization || req.http.Cookie) {<br>
><br>
>     return (pass);<br>
><br>
>   }<br>
><br>
><br>
>   if (<br>
><br>
>     req.url ~ "preview"<br>
><br>
>     || req.url ~ "nocache"<br>
><br>
>     || req.url ~ "\.css$"<br>
><br>
>     || req.url ~ "\.js$"<br>
><br>
>     || req.url ~ "\.jpg$"<br>
><br>
>     || req.url ~ "\.jpeg$"<br>
><br>
>     || req.url ~ "\.gif$"<br>
><br>
>     || req.url ~ "\.png$"<br>
><br>
>   ) {<br>
><br>
>     return (pass);<br>
><br>
>   }<br>
><br>
><br>
>   return (lookup);<br>
><br>
> }<br>
><br>
><br>
> sub vcl_hit {<br>
><br>
><br>
>   if (req.request == "PURGE") {<br>
><br>
>     purge;<br>
><br>
>     error 200 "Purged.";<br>
><br>
>   }<br>
><br>
>   return (deliver);<br>
><br>
> }<br>
><br>
><br>
> sub vcl_miss {<br>
><br>
>   if (req.request == "PURGE") {<br>
><br>
>     purge;<br>
><br>
>     error 200 "Purged.";<br>
><br>
>   }<br>
><br>
>   return (fetch);<br>
><br>
> }<br>
><br>
><br>
> sub vcl_fetch {<br>
><br>
>   set beresp.http.Vary = "Accept-Encoding";<br>
><br>
><br>
>   if (!(req.url ~ "wp-(login|admin)") && !req.http.cookie ~<br>
> "wordpress_logged_in" ) {<br>
><br>
>     unset beresp.http.set-cookie;<br>
><br>
>     set beresp.ttl = 5m;<br>
><br>
>   }<br>
><br>
><br>
>   if (beresp.ttl <= 0s ||<br>
><br>
>     beresp.http.Set-Cookie ||<br>
><br>
>     beresp.http.Vary == "*") {<br>
><br>
>       set beresp.ttl = 120 s;<br>
><br>
>       return (hit_for_pass);<br>
><br>
>   }<br>
><br>
><br>
>   return (deliver);<br>
><br>
><br>
> }<br>
><br>
><br>
> sub vcl_hash {<br>
><br>
><br>
> if (req.http.host) {<br>
><br>
>  hash_data(req.http.host);<br>
><br>
> } else {<br>
><br>
>  hash_data(server.ip);<br>
><br>
> }<br>
><br>
> }<br>
><br>
><br>
> sub vcl_deliver {<br>
><br>
>   if (obj.hits > 0) {<br>
><br>
>     set resp.http.X-Cache = "HIT";<br>
><br>
>   } else {<br>
><br>
>     set resp.http.X-Cache = "MISS";<br>
><br>
>   }<br>
><br>
> }<br>
><br>
> =======================<br>
><br>
> Thanks for help,<br>
><br>
><br>
</div></div>>       Fabio Fraga Machado<br>
> phone: <a href="tel:%2848%29%204052-8300" value="+554840528300">(48) 4052-8300</a> <<a href="http://up2it.com.br/assinatura/tel//4840528300" rel="noreferrer" target="_blank">http://up2it.com.br/<wbr>assinatura/tel//4840528300</a>><br>
> web: <a href="http://www.dataspace.com.br" rel="noreferrer" target="_blank">www.dataspace.com.br</a> <<a href="http://www.dataspace.com.br/" rel="noreferrer" target="_blank">http://www.dataspace.com.br/</a>><br>
> email: <a href="mailto:fabio@dataspace.com.br">fabio@dataspace.com.br</a> <mailto:<a href="mailto:fabio@dataspace.com.br">fabio@dataspace.com.br</a><wbr>><br>
> skype: boinkbr<br>
>   <<a href="https://facebook.com/dataspace.brasil" rel="noreferrer" target="_blank">https://facebook.com/<wbr>dataspace.brasil</a>><<a href="https://twitter.com/data_space" rel="noreferrer" target="_blank">https://<wbr>twitter.com/data_space</a>><br>
><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> varnish-misc mailing list<br>
> <a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
> <a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" rel="noreferrer" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/<wbr>varnish-misc</a><br>
><br>
<br>
</blockquote></div><br></div>