# How to Build a Self-Hosted V2Ray Server: Complete Setup Guide

> Build a self-hosted V2Ray server with our easy one-click script and pre-configured settings. Secure your internet access and bypass restrictions effortlessly.

- Repository: [如何翻墙/fanqiang](https://github.com/bannedbook/fanqiang)
- Tags: how-to-guide
- Published: 2026-08-10

---

**You can build a self-hosted V2Ray server by installing the official binary via the one-click script, deploying the pre-configured [`config.json`](https://github.com/bannedbook/fanqiang/blob/main/config.json) from the bannedbook/fanqiang repository to `/usr/local/etc/v2ray/`, and opening port 1234 in your firewall.**

The bannedbook/fanqiang repository maintains a curated collection of circumvention tools, including a minimal server configuration that wires together inbound VMess, outbound freedom, and routing rules. This guide references the exact file paths and parameters defined in [`v2ss/server-cfg/v2/config.json`](https://github.com/bannedbook/fanqiang/blob/main/v2ss/server-cfg/v2/config.json) to ensure your deployment matches the maintained upstream configuration.

## Prerequisites

Before installing V2Ray, ensure you have:

- **A Linux VPS** running Debian or Ubuntu (the repository scripts target these distributions).
- **SSH access** with root or sudo privileges to install packages and modify system services.
- **curl** installed to fetch the installation script and configuration files.

## Architecture Overview

A V2Ray server consists of three core components that handle traffic flow from client to internet:

| Component | Role | Configuration Location |
|-----------|------|------------------------|
| **Inbound** | Receives client connections via `vmess`, `vless`, or `trojan` protocols and authenticates them. | Defined in [`v2ss/server-cfg/v2/config.json`](https://github.com/bannedbook/fanqiang/blob/main/v2ss/server-cfg/v2/config.json) under the `"inbounds"` section, listening on `0.0.0.0:1234`. |
| **Outbound** | Forwards traffic to the internet using `freedom` or discards it via `blackhole`. | Configured under `"outbounds"` in the same [`config.json`](https://github.com/bannedbook/fanqiang/blob/main/config.json). |
| **Routing** | Applies policies to determine which traffic reaches which outbound (e.g., blocking private IP ranges). | Located under the `"routing"` object in [`config.json`](https://github.com/bannedbook/fanqiang/blob/main/config.json). |

The fanqiang repository provides a ready-to-use configuration that wires these components together, eliminating the need to manually define JSON schemas.

## Step-by-Step Installation

Follow these commands in order to deploy your server.

### 1. Install the Official V2Ray Binary

Run the official one-click installer maintained by the V2Fly project. This script is documented in the repository file `v2ss/V2ray官方一键安装脚本.md`.

```bash
apt-get update && apt-get install -y curl
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)

```

The installer places the binary at `/usr/local/bin/v2ray` and creates a systemd service.

### 2. Deploy the Server Configuration

Download the sample configuration from the fanqiang repository to the standard V2Ray configuration directory:

```bash
mkdir -p /usr/local/etc/v2ray
wget https://raw.githubusercontent.com/bannedbook/fanqiang/master/v2ss/server-cfg/v2/config.json \
     -O /usr/local/etc/v2ray/config.json

```

This configuration defines a **VMess inbound** on port `1234` with the UUID `7966c347-b5f5-46a0-b720-ef2d76e1836a` and TCP transport.

### 3. Start and Verify the Service

Apply the configuration by restarting the service and checking its status:

```bash
service v2ray restart
service v2ray status

```

To validate the JSON syntax without starting the service, use the test command:

```bash
/usr/local/bin/v2ray test -config /usr/local/etc/v2ray/config.json

```

### 4. Configure the Firewall

Open the inbound port (default `1234`) using UFW or your provider's security group:

```bash
ufw allow 1234/tcp
ufw reload

```

## Customizing the Server Configuration

Edit [`/usr/local/etc/v2ray/config.json`](https://github.com/bannedbook/fanqiang/blob/main//usr/local/etc/v2ray/config.json) to modify these key parameters:

- **Change the listening port**: Update the `"port"` value under `"inbounds"`.
- **Switch transport protocols**: Modify the `"network"` field to `ws` (WebSocket), `h2` (HTTP/2), or `grpc`.
- **Enable TLS**: For production deployments, refer to `v2ss/自建V2Ray+TLS翻墙方法.md` and `v2ss/V2Ray之TLS+WebSocket翻墙.md` in the repository to add XTLS or TLS+WebSocket layers.
- **Add CDN fronting**: Follow `v2ss/V2Ray之TLS+WebSocket+Nginx+CDN配置方法.md` to mask your server IP behind Cloudflare or another CDN.

## Client Configuration

Connect to your self-hosted server using the following parameters from [`v2ss/server-cfg/v2/config.json`](https://github.com/bannedbook/fanqiang/blob/main/v2ss/server-cfg/v2/config.json):

- **Address**: Your VPS public IP address.
- **Port**: `1234` (or your custom port).
- **UUID**: `7966c347-b5f5-46a0-b720-ef2d76e1836a`.
- **Network**: `tcp` (or `ws`/`h2` if you modified the transport).

For Windows clients, follow the specific guide `v2ss/Windows版V2ray客户端安装配置指南.md`. The repository also contains platform-specific tutorials for macOS, Android, and iOS in the root README.

## Troubleshooting Common Issues

If you encounter connection failures, verify these common pitfalls documented in `v2ss/自建V2ray服务器简明教程.md`:

- **Connection timeout**: The server firewall or provider security group blocks port `1234`. Confirm with `ufw status` or your VPS dashboard.
- **Handshake failure**: Mismatched transport protocols between client and server. Ensure both use the same `"network"` value (e.g., both TCP or both WebSocket).
- **Time drift**: VMess requires synchronized clocks. Sync your server time with `apt-get install -y ntp && service ntp restart`.
- **Missing binary**: If `/usr/local/bin/v2ray` does not exist, re-run the installation script from step 1.

## Summary

- The fanqiang repository provides a **minimal working configuration** at [`v2ss/server-cfg/v2/config.json`](https://github.com/bannedbook/fanqiang/blob/main/v2ss/server-cfg/v2/config.json) that you can deploy directly to `/usr/local/etc/v2ray/`.
- Use the **official one-click installer** from `v2fly/fhs-install-v2ray` to ensure you receive upstream binary updates.
- The default configuration listens on **port 1234** with VMess authentication; open this port in your firewall immediately after installation.
- Test your configuration with `/usr/local/bin/v2ray test` before restarting the service to catch JSON syntax errors.
- For enhanced security, migrate from TCP to **TLS+WebSocket** using the repository's dedicated TLS configuration guides.

## Frequently Asked Questions

### What is the default UUID in the fanqiang V2Ray configuration?

The default UUID is `7966c347-b5f5-46a0-b720-ef2d76e1836a`, as defined in [`v2ss/server-cfg/v2/config.json`](https://github.com/bannedbook/fanqiang/blob/main/v2ss/server-cfg/v2/config.json). You should change this value to a freshly generated UUID before deploying to production to prevent unauthorized access.

### Which port does the sample configuration use?

The sample configuration uses **port 1234** for the VMess inbound listener. You must open this TCP port in your firewall (using `ufw allow 1234/tcp` or your provider's security panel) for client connections to succeed.

### Can I use this setup with Cloudflare CDN?

Yes. The repository includes a specific tutorial `v2ss/V2Ray之TLS+WebSocket+Nginx+CDN配置方法.md` that explains how to place Nginx in front of V2Ray and proxy traffic through Cloudflare. This setup uses WebSocket transport over TLS to mask your server IP behind the CDN edge nodes.

### Where are the V2Ray log files located for debugging?

By default, the fanqiang [`config.json`](https://github.com/bannedbook/fanqiang/blob/main/config.json) does not specify log paths, so V2Ray writes to standard output captured by systemd. View real-time logs using `journalctl -u v2ray -f` or check the service status with `service v2ray status` to see recent error messages.