整体5个步骤
1.解析域名,A-acme证书申请
2.伪装网站搭建,安装nginx上传伪装网站文件,修改nginx.conf
3.安装xray,修改xrayconfig
4、启动xray,设为开启启动,重启xray和nginx
5、设置证书自动签
1、解析域名,A-acme证书申请
A-acme证书申请:(证书安装必须在nginx之前,不然nginx会占用80端口,懂得关闭nginx的可以无视)
apt-get install -y openssl cron socat curl unzip vim
下面这个申请代码已经更新,email=后面这里要输入你的一个邮箱要输入一个邮箱,否则会报错
curl https://get.acme.sh | sh -s email=my@example.com
source ~/.bashrc
.acme.sh/acme.sh --issue -d 你的域名 --standalone -k ec-256
.acme.sh/acme.sh --installcert -d 你的域名 --fullchainpath /etc/ssl/private/你的域名.crt --keypath /etc/ssl/private/你的域名.key --ecc
chmod 755 /etc/ssl/private
#(记得cret和key要有755的权限,没有就手动添加,不然启动xray会报错23)
acme.sh --upgrade --auto-upgrade
2.伪装网站搭建,安装nginx上传伪装网站文件,修改nginx.conf
a.安装nginx
apt update && apt install nginx -y
b.创建一个网站专用的文件夹
mkdir -p /var/www/website/html
c.把伪装站点的文件全部上传到 /var/www/website/html/
建议你自己找个静态模板,推荐国外大站的,例如 https://templated.co/
wget -O web.zip --no-check-certificate 文件链接
unzip -o -d /var/www/website/html web.zip
d.修改 nginx.conf
vi /etc/nginx/nginx.conf
将下面这段,添加在 http{} 内
server {
listen 80;
server_name 你的域名;
root /var/www/website/html;
return 301 https://$http_host$request_uri;
}
server {
listen 127.0.0.1:8080;
root /var/www/website/html;
index index.html;
add_header Strict-Transport-Security "max-age=63072000" always;
}
3.安装xray,修改xrayconfig
a.安装xray
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
b.修改xray配置文件
先生成一个UUID或者去网站随机生成一个 https://www.uuidgenerator.net/
cat /proc/sys/kernel/random/uuid
然后编辑
vi /usr/local/etc/xray/config.json
修改下面有中文标注的地方
{
"log": {
"loglevel": "debug",
"access": "/var/log/xray/access.log",
"error": "/var/log/xray/error.log"
},
"inbounds": [
{
"port": 443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "自己去生成UUID",
"flow": "xtls-rprx-direct",
"level": 0,
"email": "333@ffff.com"
}
],
"decryption": "none",
"fallbacks": [
{
"dest": 8080
}
]
},
"streamSettings": {
"network": "tcp",
"security": "xtls",
"xtlsSettings": {
"alpn": [
"http/1.1"
],
"certificates": [
{
"certificateFile": "/etc/ssl/private/你的域名.crt",
"keyFile": "/etc/ssl/private/你的域名.key"
}
]
}
}
}
],
"outbounds": [
{
"protocol": "freedom"
}
]
}
c.启动xray并设置开机自启
启动
systemctl start xray
查看xray开启状态
systemctl status xray
重启
systemctl restart xray
systemctl reload nginx
重启自动开启
systemctl enable xray
systemctl enable nginx
5、设置证书自动签
vi /etc/ssl/private/xray-cert-renew.sh
里面填入以下内容,注意修改中文注释的地方
#!/bin/bash
.acme.sh/acme.sh --install-cert -d a-你的域名 --ecc --fullchain-file /etc/ssl/private/你的域名.crt --key-file /etc/ssl/private/你的域名.key
echo "Xray Certificates Renewed"
chmod +r /etc/ssl/private/你的域名.key
echo "Read Permission Granted for Private Key"
sudo systemctl restart xray
echo "Xray Restarted"
保存后加权限
chmod +x /etc/ssl/private/xray-cert-renew.sh
设置自动任务
crontab -e
在里面输入以下代码,意思为每月1日自动申请证书
0 1 1 * * bash /etc/ssl/private/xray-cert-renew.sh
如何验证vps是不是双ips