Update from the original repo:
- Add additional notes for trouble shooting
- Update guidelines such as the latest usage of docker compose
- Add more helper script to speed up and simplify deployment
- (new) Add a simpler config of just V2Ray + WS (without DNS settings i.e. connect with IP directly)
Using Azure as an example
- Create a Virtual Machine
- Any kind of Size (schema) will work, but you can use exactly the same as mine
- Size: Standard B2s (2 vcpus, 4 GiB memory)
- Operating system: Linux (ubuntu 20.04)
- Location: Japan East
- Disk: Standard SSD
- Make sure you disable the auto-shutdown scheduling
- Any kind of Size (schema) will work, but you can use exactly the same as mine
- Once the VM creation complete
- Open necessary ports, in this case you need to open 80, 443
- Create a DNS name: such as
your-dns-name(optional: only required by TLS)- You can use a dynamic IP address
- You will be able to connect to your machine by using
your-dns-name.japaneast.cloudapp.azure.comdepending on the machine's location
For GCP you might facing these steps
sshinto your machine
- Install docker with
install_docker.sh
Legacy Steps
- Install
docker
- Download the auto setup script and run:
curl -fsSL https://get.docker.com -o get-docker.shthensh get-docker.sh- Add user to the docker user group (so you don't need
sudoto usedocker):sudo gpasswd -a $USER docker- Make docker auto start on boot:
sudo systemctl start dockerthensudo systemctl enable dockerInstall(Install Docker Compose | Docker Documentation) (Currently docker compose is a built-in)docker compose
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}mkdir -p $DOCKER_CONFIG/cli-pluginscurl -SL https://github.com/docker/compose/releases/download/v2.4.1/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-composechmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
Provide two ways of configuration
- WS + TLS (will create certification for TLS connection)
- WS Only
Common steps
- Download some CLI tools
sudo apt updatesudo apt install git vim tmux
git clone https://github.com/daviddwlee84/DockerCompose-V2Ray.gitandcd DockerCompose-V2Ray
- Pros
- This will create certification for TLS connection
- Your V2Ray server looks like normal website if you directly access it
- Cons
- You need to solve your DNS to make it reachable
- Modify settings
- Modify
your_domainandyour_email_addressininitial_https.shand execute (if you forgot this step you will have to manually modify the files, or justgit reset --hardto revert the changes and try again) docker-compose.yml- No need to modify
data/v2ray/config.json- Change id to use your own
"id": "bae399d4-13a4-46a3-b144-4af2c0004c2e"(or you can leave it as what it is) - You can generate a new UUID using this online tool: Online UUID Generator Tool (not sure what is the difference between different version UUIDs, seems not all UUID-like strings will work)
- Change id to use your own
- Modify
- Start server
tmuxdocker compose up --build(permission issue just addsudoin the front)- Exit you can use
Ctrl + bthendto detach tmux and typeexitto close the terminal
Legacy Steps
init-letsencrypt.sh
- Modify
domainsand- If you are using Azure, the
domainsisyour-dns-name.japaneast.cloudapp.azure.com(DNS name).- Note that
domainsSHOULD BE AN ARRAY, that is you should keep the parenthesis there.data/nginx/conf.d/v2ray.conf
- Modify all
your_domain- You can use vim
:%s/your_domain/your-dns-name.japaneast.cloudapp.azure.com/g- Setup Nginx and HTTPS encryption stuff
chmod +x ./init-letsencrypt.sh./init-letsencrypt.sh
- if you can't use this, might because docker need
sudopermission- must make sure the ports (firewall) are opened
- Pros
- Simple, just start the docker and that's it
- Cons
- Your IP might get banned by GFW more easily (in theory). But you can just switch to new public IP at anytime.
- Directly start server with V2Ray only:
docker compose -f docker-compose-v2ray-only.yml up -d
Type: Vmess
- Address:
your-dns-name.japaneast.cloudapp.azure.com - Port:
443 - UUID:
bae399d4-13a4-46a3-b144-4af2c0004c2e - Alert ID: 64
- Method: auto
- TLS
- enable
- allow insecure
- Transport:
websocket- Path:
/v2ray
- Path:
NOTE
- the
2. Portshould be80if you use3-B.- the
6. TLSis needed only if you follow3-A; if you use3-Byou can skip it.
NOTE: different client might use different config format, even though it look similar at a glance (using yaml...)
Clash for Windows:
- Clash for Windows Download – Clash for Windows
- Releases · clashdownload/Clash_for_Windows
- Releases · lantongxue/clash_for_windows_pkg
Releases · Fndroid/clash_for_windows_pkg
# ...
# 3-A.
proxies:
- name: "Your Customized Name"
type: vmess
server: your-dns-name.japaneast.cloudapp.azure.com
port: 443
uuid: bae399d4-13a4-46a3-b144-4af2c0004c2e
alterId: 64
cipher: auto
udp: false
tls: true
skip-cert-verify: true
network: ws
ws-opts:
path: /v2ray
# ...# ...
# 3-B.
proxies:
- name: "Your Customized Name"
type: vmess
server: your-ip-address
port: 80
uuid: bae399d4-13a4-46a3-b144-4af2c0004c2e
alterId: 64
cipher: auto
udp: false
network: ws
ws-opts:
path: /v2ray
# ...- Simply download binary for your machine and run
- Modify
~/.config/clash/config.yaml=> can consume Clash for Windows config! - Setup proxy
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890 - (Optional) Make this a system service (
systemctl)
You can see logs/ folder
Use sudo tail -f ./path/to/log.log to see the error message then debug
- If you forgot to open
80,443ports, you will fail at certbot step. Removedata/certbotfolder and try again. - If your Nginx server successfully running, you can connect to
https://your-dns-name.japaneast.cloudapp.azure.comusing a browser and see "Congratulation!" which basically is this HTML (data/nginx/html/v2ray/index.html) - You can connect to
https://your-dns-name.japaneast.cloudapp.azure.com/v2ray- If you get a 502 error, that means your V2Ray server is not running correctly.
- If you get the text "bad request", that means it is successfully running.
- If you changed UUID and failed to connect but every other thing is fine (v2ray log can see traffic income), maybe change UUID back to the default value.
- If you are using rootless docker you might found issue of binding ports < 1024.
Error response from daemon: driver failed programming external connectivity on endpoint nginx (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx): failed to bind port 0.0.0.0:80/tcp: Error starting userland proxy: error while calling PortManager.AddPort(): cannot expose privileged port 80, you can add 'net.ipv4.ip_unprivileged_port_start=80' to /etc/sysctl.conf (currently 1024), or set CAP_NET_BIND_SERVICE on rootlesskit binary, or choose a larger port number (>= 1024): listen tcp4 0.0.0.0:80: bind: permission denied- Run the Docker daemon as a non-root user (Rootless mode) | Docker Docs:
sudo setcap cap_net_bind_service=ep $(which rootlesskit)thensystemctl --user restart docker. - Check your 80 ports is working
docker run -it -p 80:80 nginxand open your IP in a browser.
- Run the Docker daemon as a non-root user (Rootless mode) | Docker Docs:
- To test you client you can use What Is My IP Address - See Your Public Address - IPv4 & IPv6 to see if the IP is changed to the server IP