前期準(zhǔn)備工作
關(guān)閉防火墻
ufw disable
更新索引和相關(guān)依賴
apt update
創(chuàng)建/var/www/html目錄存放index.html網(wǎng)頁(yè)文件
mkdir -p /var/www/html
創(chuàng)建/etc/trojan-go目錄存放config.json配置文件
mkdir -p /etc/trojan-go
簽發(fā)證書
安裝acme.sh,將my@example.com替換為你自己的郵件
wget -O - https://get.acme.sh | sh -s email=my@example.com
安裝socat,使用acme.sh申請(qǐng)證書必須安裝它
apt install -y socat
申請(qǐng)證書,將example.com替換為你自己的域名,并保證80端口沒(méi)有被占用
~/.acme.sh/acme.sh --issue -d example.com --standalone
安裝證書,將example.com替換為你自己的域名,將server.key和server.crt文件安裝在/etc/trojan-go目錄中
~/.acme.sh/acme.sh --install-cert -d example.com --key-file /etc/trojan-go/server.key --fullchain-file /etc/trojan-go/server.crt
升級(jí)acme.sh
~/.acme.sh/acme.sh --upgrade --auto-upgrade
搭建網(wǎng)站
安裝nginx搭建網(wǎng)站偽裝trojan-go程序
apt install -y nginx
編輯頁(yè)面文件,在/var/www/html目錄下創(chuàng)建index.html頁(yè)面文件
nano /var/www/html/index.html
/var/www/html/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>網(wǎng)站建設(shè)中</title>
</head>
<body>
<p>網(wǎng)站建設(shè)中</p>
</body>
</html>
搭建網(wǎng)絡(luò)代理
下載trojan-go壓縮包到你的服務(wù)器
wget https://github.com/p4gefau1t/trojan-go/releases/download/v0.10.6/trojan-go-linux-amd64.zip
解壓trojan-go-linux-amd64.zip壓縮包到trojan-go目錄中
unzip -d trojan-go trojan-go-linux-amd64.zip
拷貝trojan-go執(zhí)行文件到/usr/bin/目錄中
cp trojan-go/trojan-go /usr/bin/trojan-go
在/etc/trojan-go目錄下創(chuàng)建config.json配置文件,將配置文件中的password替換為你自己的密碼,將配置文件中的example.com替換為你自己的域名
nano /etc/trojan-go/config.json
/etc/trojan-go/config.json
{
"run_type": "server",
"local_addr": "0.0.0.0",
"local_port": 443,
"remote_addr": "127.0.0.1",
"remote_port": 80,
"password": [
"password"
],
"ssl": {
"cert": "/etc/trojan-go/server.crt",
"key": "/etc/trojan-go/server.key",
"sni": "example.com"
}
}
在/etc/trojan-go目錄下分別給server.key和server.crt文件授予權(quán)限,否則在trojan-go啟動(dòng)時(shí)沒(méi)有權(quán)限會(huì)報(bào)錯(cuò)
chmod 777 /etc/trojan-go/server.key /etc/trojan-go/server.crt
通過(guò)config.json配置文件啟動(dòng)trojan-go程序,到這里你已經(jīng)可以體驗(yàn)沖浪的快樂(lè)了
trojan-go -config /etc/trojan-go/config.json
開機(jī)啟動(dòng)服務(wù)
制作trojan-go.service服務(wù)是為了開機(jī)自動(dòng)啟動(dòng)程序
nano /etc/systemd/system/trojan-go.service
/etc/systemd/system/trojan-go.service
[Unit]
Description=Trojan-Go
After=network.target nss-lookup.target
[Service]
Type=simple
User=root
ExecStart=/usr/bin/trojan-go -config /etc/trojan-go/config.json
Restart=on-failure
RestartSec=10s
LimitNOFILE=infinity
[Install]
WantedBy=multi-user.target
開機(jī)啟動(dòng)服務(wù)的相關(guān)操作
啟動(dòng)服務(wù)
systemctl start trojan-go.service
重啟服務(wù)
systemctl restart trojan-go.service
停止服務(wù)
systemctl stop trojan-go.service
查看服務(wù)
systemctl status trojan-go.service
激活服務(wù)
systemctl enable trojan-go.service
禁用服務(wù)
systemctl disable trojan-go.service