由于百度的东西大部分对https不怎么支持,比如 百度联盟,百度爬虫(这个我无语了,实践下来确实https收录更新极慢),百度分享代码 (本站的分享代码是我自己另外改造的),不多举例了。因此有必要为百度提供特殊通道,不做https跳转。
原本的nginx配置文件是这么写的:
server
{
listen 80;
server_name ~^(.+?).cwgapibook.xdelve.com;
return 301 https://$host$request_uri;
}
server
{
listen 443;
ssl on;
ssl_certificate /pathto/cwgapibook/xdelve.chained.crt;
ssl_certificate_key /pathto/cwgapibook/xdelve.com.key;
include /pathto/nginx/cwgapibook.detail ;
}
现在改成了:
{
listen 80;
server_name ~^(.+?).cwgapibook.xdelve.com;
set $is_baidu 0;
if ($http_user_agent ~* baidu) {
set $is_baidu 1;
}
if ($request_uri ~* baidu_verify_) {
set $is_baidu 1;
}
if ($is_baidu ~ 0) {
return 301 https://$host$request_uri;
}
include /pathto/nginx/cwgapibook.detail ;
}
server
{
listen 443;
ssl on;
ssl_certificate /pathto/cwgapibook/xdelve.chained.crt;
ssl_certificate_key /pathto/cwgapibook/xdelve.com.key;
include /pathto/nginx/cwgapibook.detail ;
}
重启nginx搞定。
傻逼百度
相关文档
随便看看
畅言模块加载中