Last active
April 24, 2023 13:59
-
-
Save erfanio/64ee1b327de78faec9dd7f5922e735ef to your computer and use it in GitHub Desktop.
Setup v2ray on Ubuntu
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
# install v2ray | |
git clone https://github.com/v2fly/fhs-install-v2ray.git | |
cd fhs-install-v2ray/ | |
bash install-release.sh | |
cd .. | |
sudo systemctl enable v2ray | |
# install caddy | |
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https | |
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg | |
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list | |
sudo apt update | |
sudo apt install caddy | |
sudo curl -o /usr/bin/caddy -L 'https://caddyserver.com/api/download?os=linux&arch=amd64&p=github.com%2Fcaddy-dns%2Fcloudflare' | |
sudo systemctl enable caddy | |
echo "Edit /etc/caddy/Caddyfile to fill in details." | |
sudo mkdir -m 777 /www | |
sudo cat << EOD > /etc/caddy/Caddyfile | |
<YOUR_DOMAIN> | |
{ | |
log | |
# tls { | |
# dns cloudflare <CLOUDFLARE_TOKEN> | |
# } | |
reverse_proxy /shadowray localhost:1000 { | |
header_up -Origin | |
} | |
reverse_proxy /ray localhost:1001 { | |
header_up -Origin | |
} | |
reverse_proxy /messray localhost:1002 { | |
header_up -Origin | |
} | |
# handle_path /files/* { | |
# file_server * { | |
# root /www | |
# } | |
# } | |
handle / { | |
respond "Hello, world!" | |
} | |
} | |
EOD | |
echo "Edit /usr/local/etc/v2ray/config.json to fill in details." | |
sudo cat << EOD > /usr/local/etc/v2ray/config.json | |
{ | |
"inbounds": [ | |
{ | |
"port": 1000, | |
"listen":"127.0.0.1", | |
"protocol": "shadowsocks", | |
"settings": { | |
"method": "aes-128-gcm", | |
"password": "YOUR_PASSWORD", | |
"networks": "tcp,udp" | |
}, | |
"streamSettings": { | |
"network": "ws", | |
"wsSettings": { | |
"path": "/shadowray" | |
} | |
} | |
}, | |
{ | |
"port": 1001, | |
"listen":"127.0.0.1", | |
"protocol": "vless", | |
"settings": { | |
"decryption": "none", | |
"clients": [ { "id": "YOUR_UUID" } ] | |
}, | |
"streamSettings": { | |
"network": "ws", | |
"wsSettings": { | |
"path": "/ray" | |
} | |
} | |
}, | |
{ | |
"port": 1002, | |
"listen":"127.0.0.1", | |
"protocol": "vmess", | |
"settings": { | |
"decryption": "aes-128-gcm", | |
"clients": [ { "id": "YOUR_UUID" } ] | |
}, | |
"streamSettings": { | |
"network": "ws", | |
"wsSettings": { | |
"path": "/messray" | |
} | |
} | |
} | |
], | |
"outbounds": [ | |
{ | |
"protocol": "freedom" | |
} | |
], | |
"log": { | |
"access": "/tmp/v2ray_access.log", | |
"error": "/tmp/v2ray_error.log", | |
"loglevel": "debug" | |
} | |
} | |
EOD | |
echo "Once the config is updated to be valid, start caddy and v2ray by\nsystemctl start v2ray\nsystemctl start caddy" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment