做个站基本都有域名,有域名就可以做https认证。随着近几年对于网络安全的重视,很多大站都进行了http -> https的认证处理。更有一些平台宣布之后将不再支持http访问请求。(谷歌Chrome将不再允许HTTPS页面加载HTTP资源,关于公众平台接口不再支持HTTP方式调用等)
可见,https的改造是大势所趋。
我这里都是阿里系列的域名、服务器,默认安装了lmnp。所以采用阿里提供的免费https证书进行配置。购买及基本配置请参考官方说明“官方说明-要登录”
购买下载好之后,进行服务器上nginx的配置,我这里的配置如下:
server {
listen 80;
server_name www.deathearth.com deathearth.com;
rewrite ^/(.*) https://www.deathearth.com? permanent;
#return 301 https://$server_name$request_uri;
#index index.html index.htm index.php;
#root /alidata/www/;
#location ~ .*\.(php|php5)?$
#{
# #fastcgi_pass unix:/tmp/php-cgi.sock;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# include fastcgi.conf;
#}
#location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
#{
# expires 30d;
#}
#location ~ .*\.(js|css)?$
#{
# expires 1h;
#}
#α¾²Ì¬¹æÔò
#include /alidata/server/nginx/conf/rewrite/wordpress.conf;
#access_log /alidata/log/nginx/access/wordpress.log;
}
server {
listen 443;
server_name localhost;
index index.html index.htm index.php;
ssl on;
ssl_certificate ../cert/xxxxxxx.pem;
ssl_certificate_key ../cert/xxxxxxx.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE;
ssl_prefer_server_ciphers on;
root /alidata/www/;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
#α¾²Ì¬¹æÔò
include /alidata/server/nginx/conf/rewrite/wordpress.conf;
access_log /alidata/log/nginx/access/wordpress.log;
}
注意1
ssl_certificate …/cert/xxxxxxx.pem;
ssl_certificate_key …/cert/xxxxxxx.key;
这里相对路径是相对于nginx安装目录下 /conf/的位置。写绝对路径的话我这里没有成功。
注意2
return 301 https://$server_name$request_uri
这种写法是可以将http请求 301重定向为 https请求,但是无法通过百度https认证。会提示错误
请确保您网站的所有链接均支持https访问,且未使用不安全协议(如:SSL2、SSL3等协议)
改为下面这种配置可以正常通过认证
rewrite ^/(.*) https://www.deathearth.com? permanent;
注意, 域名后面是?不是 $1,否则也会不通过
注意3
最好先全面检查下,自己个站的出入站链接都是https的,或者会从http跳转到https。右键源码可以检查。挂在别站的友情链接可以不处理,但是有人说会影响链接权重等最好是改掉。我的小站流量不高,忽觉不计,就不去处理他了。
注意4
改造为https的网站,可能会更加受到百度的流量倾斜、抓取等。所以,没改造的快去做吧。
注意5
如果上述配置已经处理还未生效,请在百度站长平台删除站点资源,重新添加https的网站信息。其他情况请自行查找