wordpress 全站开启https的 解决过程

7年前 (2017-06-14) gtj wordpress, 杂记 0评论 已收录 844℃


1.nginx配置https协议

server {
listen 80;
listen 443 ssl http2;
ssl_certificate /app/nginx/conf/ssl/nginx/blog.cool360.org.crt;
ssl_certificate_key /app/nginx/conf/ssl/nginx/blog.cool360.org.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
ssl_stapling on;
ssl_stapling_verify on;
server_name blog.cool360.org;
if ($ssl_protocol = "") { return 301 https://$server_name$request_uri; } ###整站301跳转

ssl证书可以去腾讯云申请免费的。地址为:https://www.qcloud.com/product/ssl
然后nginx就设置好了https

2.调整wordpress网站相关配置

把一些http写死的固定链接改为https形式的。
如:wordpress后台面板————>设置---->常规设置---->
WordPress地址(URL)
https://bk.devopstack.cn
站点地址(URL)
https://bk.devopstack.cn
还有一些其他的固定设置改为https://XXXXX

3.让站内链接支持ssl

编辑主题下的functions.php文件。在最下面加入下面代码:

/* 替换图片链接为 https */
function my_content_manipulator($content){
if( is_ssl() ){
$content = str_replace('https://xxx.cn/wp-content/uploads', 'https://xxx.cn/wp-content/uploads', $content);
}
return $content;
}
add_filter('the_content', 'my_content_manipulator');

还有一些其他的小细节的设置

具体可以根据博客本身调整,然后期待已久的绿色小锁就出现了。
所以总结了下,做事情一定要有耐心和细心,然后要敢于多次调试。
更多内容可以访问:https://bk.devopstack.cn

博主

这货来去如风,什么鬼都没留下!!!

相关推荐

嗨、骚年、快来消灭0回复。

×
订阅图标按钮
Less is more!!!