-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxtrojan.sh
More file actions
153 lines (137 loc) · 3.68 KB
/
xtrojan.sh
File metadata and controls
153 lines (137 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
apt update && apt upgrade -y
echo 部署开机配置
sleep 1
mkdir /root/xray
cd /root/xray
#################################################
cat > /lib/systemd/system/xtrojan.service << EOF
[Unit]
Description=xTrojan
After=network.target nss-lookup.target
[Service]
Type=simple
ExecStart=/root/xray/xray -c /root/xray/config.json
ExecReload=/bin/kill -HUP
Restart=on-failure
RestartSec=10s
RestartPreventExitStatus=23
[Install]
WantedBy=multi-user.target
EOF
###########################################################
echo 下载文件
apt install wget unzip -y
banben=./banben
wget -qO- -t1 -T2 "https://api.github.com/repos/XTLS/Xray-core/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g' > $banben
wget "https://github.com/XTLS/Xray-core/releases/download/$(cat $banben)/Xray-linux-64.zip"
rm -rf $banben
unzip Xray-*
###########################################################
read -p "输入转发地址 需要携带https://的完整地址" zhuanfa
read -p "输入端口 可随机" Duankou
read -p "输入路径" Lujing
read -p "输入密码" Mimaa
read -p "输入域名" Yuming
read -e -p "输入证书路径" Zhengshu
if [ -e $Luji ];then
###################################################
cat > /root/xray/config.json << EOF
{
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": "$Duankou",
"protocol": "trojan",
"settings": {
"clients": [
{
"password": "$Mimaa"
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/$Lujing"
}
}
}
],
"outbounds": [
{
"tag": "direct",
"protocol": "freedom",
"settings": {}
},
{
"tag": "blocked",
"protocol": "blackhole",
"settings": {}
}
],
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"ip": [
"geoip:private"
],
"outboundTag": "blocked"
}
]
}
}
EOF
systemctl start xtrojan.service && systemctl enable xtrojan.service
#############################
apt install nginx -y
#############################
echo 'server{
listen 80;
server_name '$Yuming' ;
if ($host ~* '"$Yuming$"') {
rewrite ^/(.*)$ https://'$Yuming'/ permanent;
}
}
server {
listen 443 ssl http2;
server_name '$Yuming';
ssl_certificate '$Zhengshu'/server.crt;
ssl_certificate_key '$Zhengshu'/server.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers TLS13_AES_128_GCM_SHA256:TLS13_AES_256_GCM_SHA384:TLS13_CHACHA20_POLY1305_SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305;
location /'$Lujing' {
if ($http_upgrade != "websocket") {
return 404;
}
proxy_pass http://127.0.0.1:'$Duankou';
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 52w;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass '$zhuanfa';
}
}' > /etc/nginx/conf.d/default.conf
sed -i 's/\/\/server./\/server./g' /etc/nginx/conf.d/default.conf
##
ufw allow 80/tcp
ufw allow 443/tcp
nginx -s reload
else
证书文件不存在 请重新检查
fi