Install v2ray binary by script
# Install
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
# Remove
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove
V2ray configuration
mkdir -p /etc/v2ray
ln -s /usr/local/etc/v2ray/config.json /etc/v2ray/config.json
vim /etc/v2ray/config.json
-----
{
"log": {
"loglevel": "warning",
"error": "/var/log/v2ray/error.log",
"access": "/var/log/v2ray/access.log"
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 2001,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "46b1ad89-1234-5678-9012-fc537a66656c"
}
]
},
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"path": "/fc537a66"
}
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"routing": {
"rules": [
{
"type": "field",
"protocol": [
"bittorrent"
],
"outboundTag": "blocked"
}
]
},
"outbounds": [
{
"protocol": "freedom",
"settings": {}
},
{
"tag": "blocked",
"protocol": "blackhole",
"settings": {}
}
]
}
-----
Systemd configuration
systemctl daemon-reload
systemctl enable --now v2ray.service
Caddyfile
vim /etc/caddy/Caddyfile
-----
{
acme_dns cloudflare <your-cf-key>
order reverse_proxy before route
admin off
log {
output file /var/log/caddy/error.log
level ERROR
}
}
:80 {
redir https://{host}{uri} permanent
}
your-domain.com {
tls {
ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
curves x25519 secp521r1 secp384r1 secp256r1
alpn http/1.1 h2
}
@vmess-websocket {
path /fc537a66
header Connection *Upgrade*
header Upgrade websocket
}
reverse_proxy @vmess-websocket 127.0.0.1:2001
@host {
your-domain.com
}
route @host {
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
}
reverse_proxy https://reverse-proxy-source-domain.com {
header_up Host {upstream_hostport}
header_up X-Forwarded-Host {host}
}
}
}
-----