wordpress全站开启https之Nginx配置

2019-06-0507:25:45服务器及运维Comments3,683 views字数 1123阅读模式

wordpress全站开启https,http向https迁移的整个过程。也许你也会在谷歌里搜索 Nginx httpswordpress https。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

第一步:购买或者使用免费的SSL证书

免费的很多,比如沃通免费SSL申请地址: 、还有一个重点提一下:Let’s Encrypt (开源项目)文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

一种是自动的,还有一种是国外的通过使用OPENSSL手动创建证书  下面说说具体步骤文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

生成命令:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

openssl req -new -nodes -newkey rsa:2048 -keyout server.key -out server.csr文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

生成之后,csr文件内容copy给这些CA机构,自动给你一个crt。配合你刚刚生成的key,ok,完美。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

拿到crt和key之后,我们开始在Nginx配置https文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

# HTTP Server
server {
listen 80;
server_name kejianet.com;
rewrite ^ https://$server_name$request_uri permanent;
}文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

server {文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

listen 443 ssl http2;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

ssl_certificate /usr/local/nginx/conf/vhost/ssl/kejianet.com.crt;
ssl_certificate_key /usr/local/nginx/conf/vhost/ssl/kejianet.com.key;
ssl_ciphers "CHACHA20:GCM:HIGH:!DH:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS";
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
#ssl_stapling on;
#ssl_stapling_verify on;
#resolver 8.8.8.8 8.8.4.4 valid=300s;
#resolver_timeout 5s;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

如上,我们80端口的http全部301重定向到https。这样就不会对SEO产生什么不利的影响,百度站长明确说明:http网站和https当作同文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

一个站来处理,所以可以看到改版规则无https和http的区别,直接301完事!文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

第二步:把原网站http引用的图片和静态资源改成https

方法1:通过修改SQL即可。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

方法2:通过找到当前主题下的 文件文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

注意:引用的CSS文件中也要一并修改。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

第三步:wordpress后台改成https访问

文件中添加文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

基本上就可以了。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13395.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/yunwei/13395.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定