停止当前v2ray 服务:

systemctl disable v2ray

安装xray:

bash <(curl -L https://raw.githubusercontent.com/XTLS/Xray-install/main/install-release.sh)

调整当前已有的cert到新的位置 并改变权限

install -d -o nobody -g nogroup /etc/ssl/xray/
install -m 644 -o nobody -g nogroup /etc/letsencrypt/live/example.com/fullchain.pem -t /etc/ssl/xray/
install -m 600 -o nobody -g nogroup /etc/letsencrypt/live/example.com/privkey.pem -t /etc/ssl/xray/

创建 lets encrypt 更新脚本:

nano /etc/letsencrypt/renewal-hooks/deploy/xray.sh

输入以下信息

#!/bin/bash

XRAY_DOMAIN='example.com'

if [[ "$RENEWED_LINEAGE" == "/etc/letsencrypt/live/$XRAY_DOMAIN" ]]; then
    install -m 644 -o nobody -g nogroup "/etc/letsencrypt/live/$XRAY_DOMAIN/fullchain.pem" -t /etc/ssl/xray/
    install -m 600 -o nobody -g nogroup "/etc/letsencrypt/live/$XRAY_DOMAIN/privkey.pem" -t /etc/ssl/xray/

    sleep "$((RANDOM % 2048))"
    systemctl restart xray.service
fi

給予腳本可執行權限

chmod +x /etc/letsencrypt/renewal-hooks/deploy/xray.sh

修改wordpress 设置强制https

nano /var/www/wordpress/wp-config.php 

在文件结尾添加

/** 设置WordPress变量和包含文件。 */
$_SERVER['HTTPS'] = 'on';
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);
define( 'CONCATENATE_SCRIPTS', false );
define('FS_METHOD', direct);

记得在nginx的config 的每个server block 添加:

absolute_redirect off;
port_in_redirect off;
server_name_in_redirect off;