This repository contains Docker Compose configurations for V2Ray, enabling users to bypass firewalls.
V2Ray is a proxy tool equipped with advanced functionalities and supports protocols such as Shadowsocks, VMess, VLess, and Trojan. Currently, V2Fly maintains V2Ray, while the original V2Ray is no longer active.
The "V2Ray Single Server" configuration is the simplest way to get started with V2Ray. However, if your network or internet access is highly restricted, this configuration may not be effective.
For this configuration, a single server serves as the upstream. The flow of this solution is shown below.
Client <-> Upstream Server <-> Internet
To set up "V2Ray Single Server" using Docker Compose, follow the steps described below.
- Install Docker and Docker-compose (Official Documanetation).
- Run
git clone https://github.com/miladrahimi/v2ray-docker-compose.git
to download this repository. - Run
cd v2ray-docker-compose/v2ray-single-server
to change the directory. - Replace
<SHADOWSOCKS-PASSWORD>
inv2ray.json
with a secure password likeFR33DoM
. - If
ufw
is installed and enabled, runufw allow 8000
. - Run
docker compose up -d
. - Run
./clients.py
to generate client configurations. - (Optional) Run
./../utils/bbr.sh
to setup BBR and speed up the server network.
The default configuration uses the Shadowsocks protocol, but you can manually add any other protocols supported by V2Ray to the configuration. For detailed information on available protocols, please refer to the official documentation. For ready-to-use configuration examples, visit the official configuration examples.
The "V2Ray Upstream and Relay Servers" configuration is recommended for users with highly restricted network or internet access. When clients can't connect reliably to upstream servers, a relay server can help. The relay server must be accessible to clients and have a stable connection to upstream servers.
This configuration uses V2Ray on the upstream server, using the Shadowsocks protocol for communication with the relay server. The relay server provides Shadowsocks protocol for clients, in addition to SOCKS5 and HTTP Proxy protocols for the relay server's own use.
You will need two servers:
- Upstream Server: A server with access to the free internet, likely located in a foreign data center.
- Relay Server: A server that connects to the upstream server and is accessible to clients, ideally located in a datacenter within the same region as clients.
The flow of V2Ray Upsream and Relay Servers:
Client <-> Relay Server <-> Upstream Server <-> Internet
Step 1: Setup Upstream Server
- Install Docker and Docker-compose (Official Documanetation).
- Run
git clone https://github.com/miladrahimi/v2ray-docker-compose.git
to download this repository. - Run
cd v2ray-docker-compose/v2ray-upstream-server
to change the directory. - Replace
<UPSTREAM-PASSWORD>
inv2ray.json
with a Shadowsocks password likeFR33DoM
. - If
ufw
is installed and enabled, runufw allow 8000
. - Run
docker compose up -d
. - (Optional) Run
./../utils/bbr.sh
to setup BBR and speed up the server network.
Step 2: Setup Relay Server
- Install Docker and Docker-compose (Official Documanetation).
- Run
git clone https://github.com/miladrahimi/v2ray-docker-compose.git
to download this repository. - Run
cd v2ray-docker-compose/v2ray-relay-server
to change the directory. - Replace the following variables in
v2ray.json
with appropriate values.<RELAY-PASSWORD>
: A password for Shadowsocks user likeFR33DoM
.<UPSTREAM-IP>
: The upstream server IP address (like13.13.13.13
).<UPSTREAM-PASSWORD>
: The Shadowsocks password from the upstream server in the previous step.
- If
ufw
is installed and enabled, runufw allow 8000
. - Run
docker compose up -d
. - Run
./clients.py
to generate client configurations. - (Optional) Run
./../utils/bbr.sh
to setup BBR and speed up the server network.
The "V2Ray Behind CDN" configuration is recommended for users with highly restricted network or internet access, and when a relay server is not an option.
This configuration provides VMess protocol over Websockets + TLS + CDN (Read more) for users.
In this configuration, you need an upstream server and a domain integrated with a CDN service:
- Upstream Server: A server with access to the free internet, likely located in a foreign data center.
- CDN Service: A Content Delivery Network service like Cloudflare and ArvanCloud.
The flow of V2Ray Behind CDN:
Client <-> CDN <-> Upstream Server <-> Internet
Follow these steps to set up V2Ray, Caddy (Web server) and CDN:
- In the CDN panel, create an
A
record for the server IP with the proxy option disabled. - Install Docker and Docker-compose (Official Documanetation).
- Run
git clone https://github.com/miladrahimi/v2ray-docker-compose.git
to download this repository. - Run
cd v2ray-docker-compose/v2ray-caddy-cdn
to change the directory. - Run
cat /proc/sys/kernel/random/uuid
to generate a UUID. - Replace
<UPSTREAM-UUID>
inv2ray.json
with the generated UUID. - Replace
<EXAMPLE.COM>
incaddy/Caddyfile
with your domain/subdomain. - If
ufw
is installed and enabled, runufw allow 80
andufw allow 443
commands. - Run
docker compose up -d
. - Visit your domain/subdomain in your web browser. Wait until the homepage is loaded.
- In the CDN panel, enable the proxy option for the record created during the first step.
- Run
./vmess.py
to generate client configuration. - (Optional) Run
./../utils/bbr.sh
to setup BBR and speed up the server network.
Notes
- If you prefer using NGINX as your web server, please refer to V2Ray Behind CDN and NGINX.
- Some CDN services do not provide unlimited traffic with their free plans. Please check CDN Free Plans.
The "V2Ray as Relay for Outline" configuration is similar to the "V2Ray Upstream and Relay Servers" configuration, but it uses Outline on the upstream server instead of V2Ray. While the overall quality is comparable, Outline has a user-friendly management tool for easier user and traffic management.
You can find this configuration in the Outline Bridge Server repository.
This is the list of recommended applications for Shadowsocks protocol:
- Outline for all platforms
- ShadowsocksX-NG for macOS
- shadowsocks-libev for Linux
- shadowsocks-windows
- shadowsocks-android
- ShadowLink for iOS
This is the list of recommended applications for VMess protocol:
- Nekoray for macOS, Windows, and Linux
- FoXray for macOS, iOS, and Android
- V2Box for macOS and iOS
- V2Box for Android
- ShadowLink for iOS
- v2rayNG for Android
- v2rayN for Windows
Moved to HTTP & SOCKS Protocols.