2016-06-21 97 views
0

共享调试器没有从我的网站获取正确的数据,我发现问题是gzipnginx禁用gzip仅适用于facebook crawler

我可以禁用gzip for nginx只为Facebook crawler吗?

Inferred Property The 'og:image' property should be explicitly provided, even if a value can be inferred from other tags. Object Missing a Required Value Object at URL 'https://kida.al/13' of type 'website' is invalid because a required property 'og:title' of type 'string' was not provided.

回答

2

根据文档here,Facebook的履带将确定自己是 “facebookexternalhit”。因此,您可以禁用该用户代理的gzip。这样的事情可能工作(注意,这是未测试)

server { 
    (all settings here) 

    location ~/{ 
    if ($http_user_agent ~ facebookexternalhit) { 
     gzip off; 
    } // End iff 
    } // End Location 
} // End Server 
+0

我运行Ubuntu服务器16.04 LTS我得到这个错误:'nginx的:EMERG]“压缩”指令在这里不允许使用在/ etc/nginx/sites-enabled/default:90' –

+1

根据http://nginx.org/en/docs/http/ngx_http_gzip_module.html,gzip指令允许在http,server,location和location中。您需要将“if”块移动到“位置”块中以使其工作。 –

+0

如果在/etc/nginx/nginx.conf中不允许使用“伪指令”,那么我把它放在'http'里面,现在错误是'nginx:[emerg]“,nginx:配置文件/ etc/nginx/nginx。 conf test failed' –