forked from sbatrow/vps-xray-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xray.sh
170 lines (154 loc) · 3.63 KB
/
xray.sh
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
#input uuid & domain
echo Enter a valid gen4 UUID:
read uuid
echo Enter a valid domain:
read domain
#configure timezone to sri lanka standards
rm -rf /etc/localtime
cp /usr/share/zoneinfo/Asia/Colombo /etc/localtime
date -R
#disable ubuntu firewall
ufw disable
#running xray install script for linux - systemd
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
#adding new configuration files
rm -rf /usr/local/etc/xray/config.json
cat << EOF > /usr/local/etc/xray/config0.json
{
"inbounds": [
{
"port": 80,
"protocol": "vmess",
"tag":"http",
"settings": {
"clients": [
{
"id": "$uuid",
"level": 1,
"alterId": 4,
"security": "auto"
}
]
},
"streamSettings": {
"network": "tcp",
"tcpSettings": {
"header": {
"type": "http",
"response": {
"version": "1.1",
"status": "200",
"reason": "OK",
"headers": {
"Content-encoding": [
"gzip"
],
"Content-Type": [
"text/html; charset=utf-8"
],
"Cache-Control": [
"no-cache"
],
"Vary": [
"Accept-Encoding"
],
"X-Frame-Options": [
"deny"
],
"X-XSS-Protection": [
"1; mode=block"
],
"X-content-type-options": [
"nosniff"
]
}
}
}
}
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
]
}
EOF
cat << EOF > /usr/local/etc/xray/config1.json
{
"inbounds": [
{
"port": 443,
"protocol": "vless",
"tag":"XTLS",
"settings": {
"clients": [
{
"id": "$uuid",
"flow": "xtls-rprx-direct",
"level": 0
}
],
"decryption": "none",
"fallbacks": [
{
"dest": "www.baidu.com:80"
}
]
},
"streamSettings": {
"network": "tcp",
"security": "xtls",
"xtlsSettings": {
"alpn": [
"http/1.1"
],
"certificates": [
{
"certificateFile": "/etc/xray/xray.crt",
"keyFile": "/etc/xray/xray.key"
}
]
}
}
}
]
}
EOF
cat << EOF > /usr/local/etc/xray/config2.json
{
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}
EOF
#accuring a ssl certificate
apt-get update && apt-get install curl -y && apt-get install cron -y && apt-get install socat -y
curl https://get.acme.sh | sh
source ~/.bashrc
bash ~/.acme.sh/acme.sh --issue -d $domain --alpn -k ec-256
mkdir /etc/xray && sudo ~/.acme.sh/acme.sh --installcert -d $domain --fullchainpath /etc/xray/xray.crt --keypath /etc/xray/xray.key --ecc
chmod 644 /etc/xray/xray.key
#starting xray core on sytem startup
cat << EOF > /etc/systemd/system/xray.service.d/10-donot_touch_single_conf.conf
# In case you have a good reason to do so, duplicate this file in the same directory and make your customizes there.
# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
[Service]
ExecStart=
ExecStart=/usr/local/bin/xray run -confdir /usr/local/etc/xray/
EOF
systemctl daemon-reload
systemctl enable xray
systemctl restart xray
#install bbr
mkdir ~/across
git clone https://github.com/teddysun/across ~/across
chmod 777 ~/across
bash ~/across/bbr.sh