前提
因為VMESS被發現有漏洞很容易被偵測,所以V2Ray團隊開發了另一個更輕量的通訊協定 - VLESS
另外這個新版的VLESS協議因為沒有自身的加密,所以目前都是強制要加掛TLS(其實就是希望把加密都改成依靠TLS達到加密的安全性)
參考資料
解析 Certbot(Let’s encrypt) 使用方式
安裝
新版V2Ray安裝
Software Installation
因為VLESS已經被包括到新版的V2Ray之中(4.27以後),所以只要安裝新版的V2Ray就可以進行相關設定,一般都會改用變更後的安裝script(for Debian/Ubuntu)
Archlinux可以用pacman直接安裝與更新
1 | sudo pacman -S v2ray |
其他的請用下述的script
1 | bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) |
Setup與啟動
因為需要證書的關係,所以會建議創建v2ray帳號
1 | sudo useradd -s /usr/sbin/nologin v2ray |
並且修改systemd裡面的Service檔
1 | sudo systemctl edit v2ray.service |
內容改為
1 | [Service] |
若是使用systemctl edit指令無法修改(會變成一片白之類的),請直接使用vi指令進行修改如下
1 | sudo vi /etc/systemd/system/v2ray.service |
用這個修改的話必須update Service不然不會做數
1 | #先disable |
Certbot與相關組件安裝
因為VLESS需要跟TLS綁在一起,所以設定檔內需要fullchain.pem & private.pem的ssl key,所以以往很方便的caddy自動https作法瞬間變成沒辦法使用(應該還是可以只是得要先確定caddy的SSL Key放哪)
一般的教程會採用Certbot+Nginx或是Certbot+Apache的方式進行
Certbot安裝
Archlinux
1 | sudo pacman -S certbot |
Debian/Ubuntu
1 | sudo apt install certbot |
python-nginx
這個部份安裝的時候就會連同Nginx/Apache一起安裝了
Archlinux
1 | sudo pacman -S python3-certbot-nginx |
Debian/Ubuntu
1 | sudo apt install python3-certbot-nginx |
Certbot證書簽發與Key
這裡假設都以經將Domain與IP做好連結,所以才能簽發,這也代表VLESS的方案中Domain成為必要的前提條件之一
1 | # 自動簽發模式for nginx |
過程中會需要輸入
- Email address
- Domain
沒有異常自動模式會自動啟動Nginx或Apache進行認證,順著跑完就好了
部屬V2Ray用的SSL Key
確認Certbot建立的證書有以下
/etc/letsencrypt/live/example.com/fullchain.pem/etc/letsencrypt/live/example.com/privkey.pem
example.com是你的Domain
Renew證書設定
Archlinux
利用
systemd timer進行renewal先建立一個service for renewal
1
sudo vi /lib/systemd/system/certbot.service
1
2
3
4
5
6
7
8[Unit]
Description=Certbot
Documentation=file:///usr/share/doc/python-certbot-doc/html/index.html
Documentation=https://letsencrypt.readthedocs.io/en/latest/
[Service]
Type=oneshot
ExecStart=/usr/bin/certbot -q renew
PrivateTmp=true之後在做一個timer檔讓systemd定時執行certbot.service
1
sudo vi /etc/systemd/system/timers.target.wants/certbot.timer
1
2
3
4
5
6
7
8
9
10[Unit]
Description=Run certbot twice daily
[Timer]
OnCalendar=*-*-* 00,12:00:00
RandomizedDelaySec=43200
Persistent=true
[Install]
WantedBy=timers.target然後執行
1
sudo systemctl enable certbot.timer
1
sudo systemctl start certbot.timer
Debian
安裝Certbot後已經自動建好了上面的service/timer,所以不用自己來
建立V2Ray專用目錄
1 | sudo install -d -o v2ray -g v2ray /etc/ssl/v2ray/ |
部屬到專用目錄
1 | sudo install -m 644 -o v2ray -g v2ray /etc/letsencrypt/live/example.com/fullchain.pem -t /etc/ssl/v2ray/ |
建立Renew後的自動script
1 | sudo vi /etc/letsencrypt/renewal-hooks/deploy/v2ray.sh |
其內容如下
1 |
|
不要忘記修改example.com為自己的DN
之後給予權限
1 | sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/v2ray.sh |
BBR
Archlinux
1
2
3echo "tcp_bbr" > /etc/modules-load.d/80-bbr.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.d/80-bbr.conf
echo "net.core.default_qdisc=fq" >> /etc/sysctl.d/80-bbr.conf接著
1
sysctl -p
Debian
Debian9/10有內建BBR只要打開就可以了
1
2echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf接著
1
sysctl -p