Skip to content

V2Ray Docker Compose (Relay and Upstream Servers, Websockets + TLS + CDN, VMESS and Shadowsocks Protocols)

Notifications You must be signed in to change notification settings

miladrahimi/v2ray-docker-compose

Repository files navigation

V2Ray Docker Compose

This repository contains V2Ray-based solutions for bypassing firewalls in restricted networks where direct access to upstream servers (servers with free internet access) is unavailable.

Table of contents

Server Solutions

V2Ray Upsream and Relay Servers

The "V2Ray Upsream and Relay Servers" solution offers high stability and speed (depends on the network speeds of the relay and upstream servers).

The solution uses V2Ray on the upstream server, using the Shadowsocks protocol for communication with the relay server. The relay server provides Shadowsocks protocol for users, in addition to Socks5 and HTTP protocols for the relay server's own use.

The Shadowsocks protocol is used because it operates on layer 4, making it very fast. Additionally, there are many user-friendly client applications that support this protocol.

You will need two types of servers:

  • Upstream Server: A server with access to the free internet, likely located in a foreign data center.
  • Relay Server: A server that can connect to the upstream server and is accessible to users, likely located in the same region as the users.

The flow of V2Ray Upsream and Relay Servers:

Users <-> Relay Server <-> Upstream Server <-> Internet

Step 1: Setup Upstream Server

  1. Install Docker and Docker-compose (Official Documanetation).
  2. Run git clone https://github.com/miladrahimi/v2ray-docker-compose.git to download this repository.
  3. Run cd v2ray-docker-compose/v2ray-upstream-server to change the directory.
  4. Replace <UPSTREAM-PASSWORD> in v2ray.json with a Shadowsocks password like FR33DoM.
  5. Run docker compose up -d.
  6. (Optional) Run ./../utils/bbr.sh to setup BBR and speed up the server network.

Step 2: Setup Relay Server

  1. Install Docker and Docker-compose (Official Documanetation).
  2. Run git clone https://github.com/miladrahimi/v2ray-docker-compose.git to download this repository.
  3. Run cd v2ray-docker-compose/v2ray-relay-server to change the directory.
  4. Replace the following variables in v2ray.json with appropriate values.
    • <RELAY-PASSWORD>: A password for Shadowsocks users like FR33DoM.
    • <UPSTREAM-IP>: The upstream server IP address (like 13.13.13.13).
    • <UPSTREAM-PASSWORD>: The Shadowsocks password from the upstream server in the previous step.
  5. Run docker compose up -d.
  6. Run ./clients.py to generate client configurations and links.
  7. (Optional) Run ./../utils/bbr.sh to setup BBR and speed up the server network.

V2Ray Behind CDN

The "V2Ray Behind CDN" solution is recommended only if you don't have relay server to implement other solutions.

This solution provides VMess over Websockets + TLS + CDN (Read more) for users.

In this solution, you need upstream server and a domain added to 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:

Users <-> CDN <-> Upstream Server <-> Internet

Follow these steps to set up V2Ray, Caddy (Web server) and CDN:

  1. In the CDN panel, create an A record for the server IP with the proxy disabled.
  2. Install Docker and Docker-compose (Official Documanetation).
  3. Run git clone https://github.com/miladrahimi/v2ray-docker-compose.git to download this repository.
  4. Run cd v2ray-docker-compose/v2ray-caddy-cdn to change the directory.
  5. Run cat /proc/sys/kernel/random/uuid to generate a UUID.
  6. Replace <UPSTREAM-UUID> in v2ray.json with the generated UUID.
  7. Replace <EXAMPLE.COM> in caddy/Caddyfile with your domain/subdomain.
  8. Run docker compose up -d.
  9. Visit your domain/subdomain in your web browser. Wait until the homepage is loaded.
  10. In the CDN panel, enable the proxy option for the record created during the first step.
  11. Run ./vmess.py to generate client configuration link.
  12. (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_NGINX_CDN.
  • Some CDN services do not provide unlimited traffic with their free plans. Please check CDN Free Plans.
  • You can skip step 10 and keep the proxy off, but this could lead to quicker server blocking.

V2Ray as Relay for Outline

This highly recommended solution is stable and easy to set up. Using the Outline Manager app, you can setup servers, create and manage users and track their traffic. It supports Shadowsocks protocol and offers the user-friendly Outline client application.

Read more: Outline Bridge Server

Client Applications

Shadowsocks Protocol

This is the list of recommended applications to use the Shadowsocks protocol:

VMess Protocol

This is the list of recommended applications to use the VMess protocol:

HTTP and SOCKS Protocols

Moved here: HTTP_SOCKS

Links