一、nginx添加ssl模块
首先确认下自己的nginx是否有ssl模块,如没有,需要补安全,可以参考这篇文章《Nginx安装SSL模块教程及注意事项》。
二、nginx配置
# 这个server是为了http跳转https配置 server { listen 80; listen [::]:80; #监听ipv6 #listen www.mysql360.com:80; #此处添加你要该链接访问的域名 server_name www.mysql360.com; # 可以放多个,用空格隔开 rewrite ^(.*) https://$server_name$1 permanent; #http 跳转 https } # 这个是https配置 server { listen 443 ssl; # https server_name www.mysql360.com; # ssl on; nginx版本在1.15.x版本之后的,ssl on; 要去掉,listen 443; 改为 listen 443 ssl # 下面两行是ssl证书存放绝对路径,证书可以直接在阿里云控制台申请 ssl_certificate /xxxxxxxx/5174800_www.mysql360.com.pem; ssl_certificate_key /xxxxxx/5174800_www.mysql360.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_session_timeout 10m; ssl_session_cache shared:SSL:10m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; root /usr/local/xxxxx; location / { root /usr/local/xxxxxx; index index.html index.htm index.php; try_files $uri $uri/ /index.php?q=$uri&$args; } # PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI协议默认配置. # Fastcgi服务器和程序(PHP,Python)沟通的协议. location ~ \.php$ { # 设置脚本文件请求的路径 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 设置监听端口 fastcgi_pass localhost:9000; # fastcgi_pass unix:/run/php-fpm/www.sock; # 设置nginx的默认首页文件(上面已经设置过了,可以删除) fastcgi_index index.php; # 引入fastcgi的配置文件 include fastcgi_params; } }
三、修改wordpress站点url从http换为https前缀
四、站点旧文章的内容替换
三和四的内容和《阿里云虚拟主机wordpress网站绑定的域名如何从http换成https?》里一样,这边就不重复写了。
标签:index,http,ssl,server,nginx,wordpress,https,fastcgi From: https://www.cnblogs.com/shamo89/p/17060580.html