2013-08-17 40 views
1

嗨我有一个非常奇怪的问题与Wordpress 3.5 Varnish 3.02和Ubuntu的可视化编辑器已经消失。在html/visual之间切换的按钮已经消失,只有html编辑器正在显示。该网站缓存很好,没有JavaScript错误,并没有在Apache日志中的错误。 Varnish正在80和8080上听Apache。除编辑器外,其他所有工作都很好。 当我绕过清漆编辑开关按钮出现并工作正常。以下是我迄今所做的没有成功: - 禁用 所有的插件 - 切换到默认主题 - 经过萤火虫任何jQuery的错误(NONE) - 旁路光油(一切正常) - 吹扫光油缓存(没有运气) - 重新上传所有默认的wordpress文件 - 切换到Wordpress的早期版本(3.5) 您认为可能是什么问题?在这个问题上,我一直在摸索着一个星期。与wordpress的光油打破了WordPress的可视化编辑器?

VCL FILE

backend default { 
    .host = "x.x.x.x"; 
    .port = "8080"; 
} 


sub vcl_recv { 

    if (req.http.host ~ "mydomain.com") { 
    set req.http.x-Redir-Url = "http://www.anotherdomain.com/specific_folder/"; 
    error 750 req.http.x-Redir-Url; 
    } 

} 

include "devicedetect.vcl"; 

# Called after a document has been successfully retrieved from the backend. 
sub vcl_recv { 
    call devicedetect; 


    # Allow the back-end to serve up stale content if it is responding slowly. 
    set req.grace = 2m; 

    # Always cache the following file types for all users. 
    if (req.url ~ "(?i)\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(\?[a-z0-9]+)?$") { 
      unset req.http.cookie; 
    } 

    # Don't serve cached pages to logged in users 
    if (req.http.cookie ~ "wordpress_logged_in" || req.url ~ "vaultpress=true") { 
      return(pass); 
    } 

    # Drop any cookies sent to WordPress. 
    if (! (req.url ~ "wp-(login|admin)")) { 
      unset req.http.cookie; 
    } 

    # Handle compression correctly. Different browsers send different 
    # "Accept-Encoding" headers, even though they mostly all support the same 
    # compression mechanisms. By consolidating these compression headers into 
    # a consistent format, we can reduce the size of the cache and get more hits. 
    # @see: http://varnish.projects.linpro.no/wiki/FAQ/Compression 
    if (req.http.Accept-Encoding) { 

      if (req.http.Accept-Encoding ~ "gzip") { 
        # If the browser supports it, we'll use gzip. 
        set req.http.Accept-Encoding = "gzip"; 
      } 

      else if (req.http.Accept-Encoding ~ "deflate") { 
        # Next, try deflate if it is supported. 
        sset req.http.Accept-Encoding = "deflate"; 
      } 
      else { 
        # Unknown algorithm. Remove it and send unencoded. 
        unset req.http.Accept-Encoding; 
      } 

    } 

} 

# MOBILE AND UA DETECTION - override the header before it is sent to the backend 
sub vcl_miss { if (req.http.X-UA-Device) { set bereq.http.User-Agent = req.http.X-UA-Device; } } 
sub vcl_pass { if (req.http.X-UA-Device) { set bereq.http.User-Agent = req.http.X-UA-Device; } } 


sub vcl_fetch { 
    #SET UA BEFORE SENDING TO BACKEND 
    if (req.http.X-UA-Device) { 
      if (!beresp.http.Vary) { # no Vary at all 
        set beresp.http.Vary = "X-UA-Device"; 
      } elseif (beresp.http.Vary !~ "X-UA-Device") { # add to existing Vary 
        set beresp.http.Vary = beresp.http.Vary + ", X-UA-Device"; 
      } 
    } 
    set beresp.http.X-UA-Device = req.http.X-UA-Device; 



    #Fix Login under wordpress 
    if (beresp.http.set-cookie ~ "sessionid" || beresp.http.set-cookie ~ "csrftoken") { 
    #  return (pass); 
    } else { 
      return (deliver); 
    } 

    set beresp.ttl = 20m; 

    # Allow items to be stale if needed. 
    set beresp.grace = 2m; 

    # Drop any cookies WordPress tries to send back to the client. 
    if (! req.url ~ "wp-(login|admin)" && ! req.http.cookie ~ "wordpress_logged_in") { 
      unset beresp.http.set-cookie; 
    } 

} 

sub vcl_error { 
#REDIRECTION 
    if (obj.status == 750) { 
      set obj.http.Location = obj.response; 
      set obj.status = 301; 
      return (deliver); 
    } 

set obj.http.Content-Type = "text/html; charset=utf-8"; 
set obj.http.Retry-After = "5"; 
synthetic {" 
    <?xml version="1.0" encoding="utf-8"?> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html> 
    <head> 
    <title>OOPS UNE ERREUR S'EST PRODUITE</title> 
    <style src="css/style.css"></style> 
    </head> 
    <body> 
    <h1>Oh! Oh! Nos excuses. Une erreure s'est produite. On s'en occupe.</h1> 
    </body> 
    </html> 
"}; 
    return (deliver); 
} 

sub vcl_deliver { 
    if ((req.http.X-UA-Device) && (resp.http.Vary)) { 
    set resp.http.Vary = regsub(resp.http.Vary, "X-UA-Device", "User-Agent"); 
    } 
} 


**************THIS IS ANOTHER FILE(devicedetect.vcl)********************** 

INCLUDED DEVICE DETECTION: 

# 
# detectdevice.vcl - regex based device detection for Varnish 
# http://github.com/varnish/varnish-devicedetect/ 
# 
# Author: Lasse Karstensen <[email protected]> 

sub devicedetect { 
    unset req.http.X-UA-Device; 
    set req.http.X-UA-Device = "pc"; 

    # Handle that a cookie may override the detection alltogether. 
    if (req.http.Cookie ~ "(?i)X-UA-Device-force") { 
      /* ;?? means zero or one ;, non-greedy to match the first. */ 
      set req.http.X-UA-Device = regsub(req.http.Cookie, "(?i).*X-UA-Device-force=([^;]+);??.*", "\1"); 
      /* Clean up our mess in the cookie header */ 
      set req.http.Cookie = regsuball(req.http.Cookie, "(^|;) *X-UA-Device-force=[^;]+;? *", "\1"); 
      /* If the cookie header is now empty, or just whitespace, unset it. */ 
      if (req.http.Cookie ~ "^ *$") { unset req.http.Cookie; } 
    } else { 
      if (req.http.User-Agent ~ "(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot" || 
       req.http.User-Agent ~ "(?i)(baidu|jike|symantec)spider" || 
       req.http.User-Agent ~ "(?i)scanner" || 
       req.http.User-Agent ~ "(?i)(web)crawler") { 
        set req.http.X-UA-Device = "bot"; } 
      elsif (req.http.User-Agent ~ "(?i)ipad")  { set req.http.X-UA-Device = "tablet-ipad"; } 
      elsif (req.http.User-Agent ~ "(?i)ip(hone|od)") { set req.http.X-UA-Device = "mobile-iphone"; } 
      /* how do we differ between an android phone and an android tablet? 
       http://stackoverflow.com/questions/5341637/how-do-detect-android-tablets-in-general-useragent */ 
      elsif (req.http.User-Agent ~ "(?i)android.*(mobile|mini)") { set req.http.X-UA-Device = "mobile-android"; } 
      // android 3/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout. 
      elsif (req.http.User-Agent ~ "(?i)android 3")    { set req.http.X-UA-Device = "tablet-android"; } 
      // May very well give false positives towards android tablets. Suggestions welcome. 
      elsif (req.http.User-Agent ~ "(?i)android")   { set req.http.X-UA-Device = "tablet-android"; } 
      elsif (req.http.User-Agent ~ "Mobile.+Firefox")  { set req.http.X-UA-Device = "mobile-firefoxos"; } 
      elsif (req.http.User-Agent ~ "^HTC" || 
       req.http.User-Agent ~ "Fennec" || 
       req.http.User-Agent ~ "IEMobile" || 
       req.http.User-Agent ~ "BlackBerry" || 
       req.http.User-Agent ~ "SymbianOS.*AppleWebKit" || 
       req.http.User-Agent ~ "Opera Mobi") { 
        set req.http.X-UA-Device = "mobile-smartphone"; 
      } 
      elsif (req.http.User-Agent ~ "(?i)symbian" || 
       req.http.User-Agent ~ "(?i)^sonyericsson" || 
       req.http.User-Agent ~ "(?i)^nokia" || 
       req.http.User-Agent ~ "(?i)^samsung" || 
       req.http.User-Agent ~ "(?i)^lg" || 
       req.http.User-Agent ~ "(?i)bada" || 
       req.http.User-Agent ~ "(?i)blazer" || 
       req.http.User-Agent ~ "(?i)cellphone" || 
       req.http.User-Agent ~ "(?i)iemobile" || 
       req.http.User-Agent ~ "(?i)midp-2.0" || 
       req.http.User-Agent ~ "(?i)u990" || 
       req.http.User-Agent ~ "(?i)netfront" || 
       req.http.User-Agent ~ "(?i)opera mini" || 
       req.http.User-Agent ~ "(?i)palm" || 
       req.http.User-Agent ~ "(?i)nintendo wii" || 
       req.http.User-Agent ~ "(?i)playstation portable" || 
       req.http.User-Agent ~ "(?i)portalmmm" || 
       req.http.User-Agent ~ "(?i)proxinet" || 
       req.http.User-Agent ~ "(?i)sonyericsson" || 
       req.http.User-Agent ~ "(?i)symbian" || 
       req.http.User-Agent ~ "(?i)windows\ ?ce" || 
       req.http.User-Agent ~ "(?i)winwap" || 
       req.http.User-Agent ~ "(?i)eudoraweb" || 
       req.http.User-Agent ~ "(?i)htc" || 
       req.http.User-Agent ~ "(?i)240x320" || 
       req.http.User-Agent ~ "(?i)avantgo") { 
        set req.http.X-UA-Device = "mobile-generic"; 
      } 
    } 

}

+0

我自己也尝试紧迫,取消勾选用户>>公司简介>>可视化编辑器。 – Chefou

+0

我已经将连接脚本和调试脚本选项添加到wp-config中,但没有成功。 – Chefou

+0

我也尝试了不同的浏览器,个人电脑和清除浏览器缓存和饼干。 – Chefou

回答

2

是它发生不论是会员或没有。

问题出在vcl_recv中调用devicedetect。我在第一个处理devicedetect例程后创建了一个新的vcl_recv。这不知怎的解决了这个问题。

谢谢

2

我已经偶然发现了这个问题,同时遇到同样的问题。我试图按照提问者在后续“回复”中提出的建议,但我运气不佳。

问题中描述的问题源于Wordpress仅在用户代理匹配已知类型时启用TinyMCE(可视化)编辑器的事实。对于其他一切,它会默认禁用它。结合devicedetect.vcl,你大概可以看到这是怎么回事...

因此,因为我们发送“pc”,“移动平台”等到后端(Wordpress),它永远不会真正知道浏览器您正在使用。

在我的VCL我禁用/可湿性粉剂管理员缓存完全用下面的代码:

if (req.url ~ "/wp-(login|admin)") { 
    return (pass); 
} 

当我实现devicedetect.vcl我在我的sub vcl_recv顶部调用程序,因此用户代理是已经以修改的状态到达我的后端。

的解决方案是return (pass)/wp-(login|admin)之前call devicedetect,像这样:

if (req.url ~ "/wp-(login|admin)") { 
    return (pass); 
} 
call devicedetect; 
相关问题