Skip to content

Instantly share code, notes, and snippets.

@amphineko
Last active May 24, 2023 14:27
Show Gist options
  • Save amphineko/a8b8d4d278e92bc579e71b67c790b35b to your computer and use it in GitHub Desktop.
Save amphineko/a8b8d4d278e92bc579e71b67c790b35b to your computer and use it in GitHub Desktop.
V2Ray with outbound address (cursed way)

There're some Docker-ized configuration files to setup a weird proxy.
Since V2Ray doesn't support specifiy outbound address yet,
placing a Shadowsocks instance with -b option behind the V2Ray server is less complex than policy routing in the kernel.

The whole proxy chain for this VMess over WebSocket:
Reverse Proxy (NGINX, etc.) -> V2Ray (WebSocket -> VMess) -> Shadowsocks

version: '3'
services:
shadowsocks:
command: ss-server -c /etc/shadowsocks/config.json -b <PUT OUTBOUND ADDRESS HERE>
image: shadowsocks/shadowsocks-libev
network_mode: host
restart: always
volumes:
- ./shadowsocks.json:/etc/shadowsocks/config.json
v2ray:
image: v2ray/official
network_mode: host
restart: always
volumes:
- ./v2ray.json:/etc/v2ray/config.json
{
"server": ["127.0.0.1"],
"mode": "tcp_and_udp",
"server_port": 17801,
"password": "password",
"timeout": 60,
"method": "aes-128-gcm"
}
{
"log": {
"error": "/var/log/v2ray/error.log",
"loglevel": "warning",
"access": "/var/log/v2ray/access.log"
},
"stats": {},
"inbounds": [
{
"port": 17802,
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"path": "<PUT WEBSOCKET PATH HERE>"
}
},
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "<PUT CLIENT UUID HERE>",
"alterId": 32
}
]
},
"tag": "in-0"
}
],
"outbounds": [
{
"protocol": "shadowsocks",
"settings": {
"servers": [
{
"address": "127.0.0.1",
"port": 17801,
"method": "aes-128-gcm",
"password": "password"
}
]
},
"tag": "direct"
},
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
],
"routing": {
"rules": [
{
"ip": [
"geoip:private"
],
"type": "field",
"outboundTag": "blocked"
}
],
"domainStrategy": "AsIs"
},
"policy": {},
"reverse": {},
"transport": {}
}
@amphineko
Copy link
Author

amphineko commented Jul 29, 2019

TODO

  • Multiple instances of V2Ray and load balancing (if necessary?)
  • Retrieve parameters in JSON files from environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment