Setting up V2Ray on a DigitalOcean VPS gives you a robust, high-performance proxy with flexibility for multiple protocols, strong encryption, and good integration with standard web infrastructure. The following walkthrough assumes familiarity with Linux server administration and targets site owners, sysadmins, and developers who need a secure, production-ready deployment backed by TLS, a reverse proxy, and basic hardening.
Prerequisites and planning
Before you begin, prepare the following:
- A DigitalOcean account and ability to create a Droplet.
- Domain name pointed to the Droplet’s public IP (A record).
- Basic Linux command-line knowledge and SSH access.
- Ubuntu 22.04 LTS (recommended) or Debian 11/12 as OS on the Droplet.
Decide on a transport and protocol: commonly VLESS over WebSocket with TLS or VMess over WebSocket with TLS. WebSocket + TLS is compatible with browser-hosted clients and is easy to proxy via Nginx for certificate management. For best performance with modern clients, consider VLESS + XTLS if clients support it, but here we’ll use TLS+WS for the widest compatibility.
Droplet creation and initial hardening
Create a Droplet (1 vCPU, 1–2 GB RAM is enough for lightweight use) and choose Ubuntu 22.04. When Droplet is ready, connect via SSH:
ssh root@your_server_ip
Then do initial system updates and create a non-root sudo user:
apt update && apt upgrade -y
adduser deployer
usermod -aG sudo deployer
Set up basic firewall rules using UFW:
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
Keep SSH on the default port for now, or harden later (change SSH port, disable password authentication, add public-key only access). Install essential packages:
apt install -y nginx certbot python3-certbot-nginx curl unzip
Install V2Ray core
V2Ray core can be installed by downloading the official release. Use the project’s GitHub release to fetch the latest stable version. As root or sudo:
curl -L -s https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-linux-64.zip -o /tmp/v2ray.zip
unzip /tmp/v2ray.zip -d /tmp/v2ray
cp /tmp/v2ray/v2ray /usr/local/bin/
cp /tmp/v2ray/v2ctl /usr/local/bin/
chmod +x /usr/local/bin/v2ray /usr/local/bin/v2ctl
Create necessary directories and move files:
mkdir -p /etc/v2ray /var/log/v2ray
cp -r /tmp/v2ray/*.json /etc/v2ray/
Next create a systemd service unit so v2ray starts automatically:
<pre>[Unit]
Description=V2Ray Service
After=network.target nss-lookup.target
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
ExecStart=/usr/local/bin/v2ray -config /etc/v2ray/config.json
Restart=on-failure [Install] WantedBy=multi-user.target
</pre>
Save that as /etc/systemd/system/v2ray.service. Then enable and start:
systemctl daemon-reload
systemctl enable –now v2ray
journalctl -u v2ray -f
V2Ray JSON configuration: VLESS/VMess over WebSocket
Create a config that runs on localhost and exposes a WebSocket endpoint that Nginx will reverse-proxy. Example VLESS JSON (save as /etc/v2ray/config.json):
<pre>{
“log”: {
“access”: “/var/log/v2ray/access.log”,
“error”: “/var/log/v2ray/error.log”,
“loglevel”: “warning”
},
“inbounds”: [
{
“port”: 1270,
“listen”: “127.0.0.1”,
“protocol”: “vless”,
“settings”: {
“clients”: [
{
“id”: “YOUR-UUID-HERE”,
“flow”: “”,
“level”: 0
}
],
“decryption”: “none”
},
“streamSettings”: {
“network”: “ws”,
“wsSettings”: {
“path”: “/ray”
}
}
}
],
“outbounds”: [
{
“protocol”: “freedom”,
“settings”: {}
}
]
}
Notes:
- Replace YOUR-UUID-HERE with a strong UUID (generate with uuidgen or v2ctl uuid).
- Use 1270 or any high port on loopback to avoid exposing V2Ray directly.
- Change the path (here /ray) to a custom random path to reduce probing.
Configure Nginx as a reverse proxy with TLS
We use Nginx to terminate TLS and proxy WebSocket traffic to V2Ray. Create an Nginx server block:
<pre>server {
listen 80;
server_name your.domain.example;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
server_name your.domain.example;
ssl_certificate /etc/letsencrypt/live/your.domain.example/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your.domain.example/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
# Proxy WebSocket to V2Ray
location /ray {
proxy_redirect off;
proxy_pass http://127.0.0.1:1270;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
# Optional: other static or application locations
}
</pre>
Replace your.domain.example with your actual domain and match the /ray path. Create the directory for Certbot challenges:
mkdir -p /var/www/certbot
Obtain a certificate using Certbot:
certbot certonly –webroot -w /var/www/certbot -d your.domain.example
After certificates are issued, reload Nginx:
systemctl restart nginx
Client configuration and verification
On client side (V2RayN, V2RayNG, v2ray-core client, or apps supporting VLESS/VMess), configure:
- Address: your.domain.example
- Port: 443
- UUID: same as server
- Protocol: VLESS (or VMess if you used that server config)
- Transport: WebSocket
- Path: /ray (must match server)
- Security/TLS: TLS enabled, verify certificate (recommended)
Test connectivity and check logs on the server:
tail -f /var/log/v2ray/access.log /var/log/v2ray/error.log
Security hardening and operational tips
- Limit exposure: Keep V2Ray listening on 127.0.0.1 and let only Nginx handle public traffic.
- Use strong UUIDs: Rotate UUIDs if you suspect a leak. Use unique credentials per client if possible.
- Harden SSH: Use key-based authentication, disable root login, consider changing SSH port and installing fail2ban.
- Rate limits and DoS protection: Use Nginx rate limiting (limit_conn, limit_req) to reduce brute-force and abuse.
- Monitoring: Monitor CPU, memory, and network using tools like netdata, Prometheus + node_exporter or top/htop for quick checks.
- Automatic renewals: Ensure Certbot renewals work: add a cron job or systemd timer and test with certbot renew –dry-run.
- Logging policy: Set loglevel to warning or error in production to avoid large logs; rotate logs via logrotate.
Performance tuning
- For high throughput, ensure the VPS has sufficient network bandwidth and consider upgrading to a plan with dedicated NIC resources.
- Use TLSv1.3 and modern ciphers in Nginx for better performance (reduced handshake latency).
- Tune TCP settings (tcp_tw_reuse, tcp_window_scaling) only when needed and after testing.
- If you have many simultaneous clients, increase file descriptor limits (nofile) for v2ray systemd unit and OS.
Troubleshooting checklist
- Cannot connect: verify Nginx is proxying correctly (check nginx -t and access logs).
- Certificate errors: confirm Certbot issued certs and that fullchain.pem and privkey.pem paths are correct.
- WebSocket upgrade failing: ensure proxy_set_header Upgrade and Connection “upgrade” are present in Nginx location block.
- V2Ray logs: check error.log for internal JSON parsing or runtime issues.
- Firewall blocking: confirm UFW allows 80 and 443 and that no cloud provider firewall blocks traffic.
Advanced options
Once comfortable with the basics, you can explore:
- XTLS and VLESS: For improved performance and reduced TLS overhead, use XTLS if client and server both support it (requires specific configuration and a port directly exposed for XTLS).
- Multiplexing: Enable multiplexing in V2Ray if many short-lived connections exist to improve throughput (use with care and test).
- Load balancing and clustering: For scale, put multiple V2Ray nodes behind a load balancer or use DNS-based load distribution with different UUIDs.
- Use Caddy instead of Nginx: Caddy automatically provisions TLS and handles WebSocket reverse proxying with simpler configuration and strong defaults.
Summary and maintenance checklist
Deploying V2Ray on a DigitalOcean Droplet with Nginx and Certbot provides a balanced tradeoff between security, compatibility, and manageability. Key steps to maintain a healthy deployment:
- Keep system and packages up to date (apt upgrade regularly).
- Monitor logs and resource usage.
- Automate certificate renewal and test it.
- Change credentials when needed and keep per-client configuration where possible.
Following these guidelines will help you run a stable, secure, and high-speed V2Ray service suitable for production use.
For additional resources, configuration snippets, and managed offerings, visit Dedicated-IP-VPN at https://dedicated-ip-vpn.com/.