Last active
March 7, 2020 09:38
-
-
Save usbuild/686ddbbbce89233d1a521d25fb401054 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DOMAIN=$1 | |
// 开启bbr | |
modprobe tcp_bbr | |
echo "tcp_bbr" | tee --append /etc/modules-load.d/modules.conf | |
echo "net.core.default_qdisc=fq" | tee --append /etc/sysctl.conf | |
echo "net.ipv4.tcp_congestion_control=bbr" | tee --append /etc/sysctl.conf | |
sysctl -p | |
// 安装程序 | |
apt install -y supervisor nginx git curl | |
systemctl start nginx | |
systemctl start supervisor | |
// download v2ray | |
wget https://github.com/v2ray/v2ray-core/releases/download/v4.22.1/v2ray-linux-64.zip | |
mkdir v2ray | |
cd v2ray | |
unzip ../v2ray-linux-64.zip | |
cd .. | |
cp -r v2ray /usr/share/ | |
UUID=$(python -c "import uuid;print(uuid.uuid4())" | tr -d '\n') | |
cat << EOF > /usr/share/v2ray/config.json | |
{ | |
"inbounds": [ | |
{ | |
"port": 10000, | |
"listen":"127.0.0.1", | |
"protocol": "vmess", | |
"settings": { | |
"clients": [ | |
{ | |
"id": "$UUID", | |
"alterId": 64 | |
} | |
] | |
}, | |
"streamSettings": { | |
"network": "ws", | |
"wsSettings": { | |
"path": "/ray" | |
} | |
} | |
} | |
], | |
"outbounds": [ | |
{ | |
"protocol": "freedom", | |
"settings": {} | |
} | |
] | |
} | |
EOF | |
cat << EOF > /etc/supervisor/conf.d/v2ray.conf | |
[program:v2ray] | |
directory=/usr/share/v2ray/ | |
command=/usr/share/v2ray/v2ray -config config.json | |
autorestart=true | |
autostart=true | |
stderr_logfile=/var/log/v2ray_stderr.log | |
stdout_logfile=/var/log/v2ray_stdout.log | |
numprocs=1 | |
numprocs_start=0 | |
user=root | |
EOF | |
supervisorctl update | |
curl https://get.acme.sh | sh | |
~/.acme.sh/acme.sh --issue -d $DOMAIN -w /var/www/html | |
keypath=$HOME/.acme.sh/$DOMAIN/$DOMAIN.key | |
cerpath=$HOME/.acme.sh/$DOMAIN/fullchain.cer | |
cat << EOF > /etc/nginx/sites-enabled/v2ray | |
server { | |
listen 443 ssl; | |
server_name $DOMAIN; | |
ssl_certificate $cerpath; | |
ssl_certificate_key $keypath; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; | |
ssl_prefer_server_ciphers on; | |
ssl_session_cache shared:SSL:10m; | |
ssl_session_timeout 10m; | |
error_page 497 https://$host$request_uri; | |
location /ray { | |
proxy_pass http://127.0.0.1:10000; | |
proxy_redirect off; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade \$http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header Host \$http_host; | |
} | |
location / { | |
resolver 8.8.8.8; | |
proxy_pass https://lwn.net; | |
proxy_set_header Host lwn.net; | |
} | |
} | |
EOF | |
systemctl restart nginx | |
systemctl enable nginx | |
echo $UUID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment