This guide provides step-by-step instructions for setting up a VMESS server on an Ubuntu server.
- Ubuntu Server: Ensure you have an Ubuntu server up and running.
- Root Access: Access to the server with root privileges.
- Domain Name (optional): If you plan to use a domain, ensure DNS records point to your server's IP.
sudo apt update && sudo apt upgrade -yUse the official V2Ray installation script:
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)This script installs V2Ray binaries and configures the necessary directories:
- Executable:
/usr/local/bin/v2ray - Configuration:
/usr/local/etc/v2ray/config.json
Edit the default configuration file:
sudo nano /usr/local/etc/v2ray/config.json{
"inbounds": [
{
"port": 12345,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "86D4AF88-8101-490D-8E94-FF12D513CCE0",
"alterId": 64
}
]
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}port: The port for your VMESS server (e.g.,12345).id: A UUID for client authentication (generate one usinguuidgen).alterId: Additional encryption setting, typically64.
Save and exit (CTRL+O, ENTER, CTRL+X).
Start the V2Ray service:
sudo systemctl start v2rayEnable it to start on boot:
sudo systemctl enable v2rayCheck the status to ensure it is running:
sudo systemctl status v2rayAllow traffic on the VMESS port (e.g., 12345):
sudo ufw allow 12345/tcp
sudo ufw allow 12345/udpEnable the firewall if not already enabled:
sudo ufw enablesudo apt install nginx -yEdit the Nginx configuration file:
sudo nano /etc/nginx/sites-available/v2rayAdd the following configuration:
server {
listen 80;
server_name yourdomain.com;
location /v2ray {
proxy_pass http://127.0.0.1:12345;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}Enable the configuration:
sudo ln -s /etc/nginx/sites-available/v2ray /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginxInstall Certbot:
sudo apt install certbot python3-certbot-nginx -yRun Certbot to get a certificate:
sudo certbot --nginx -d yourdomain.com- Open your V2Ray client (e.g., v2box).
- Enter the following details:
- Server Address: Your server IP or domain name.
- Port:
12345(or443if using TLS). - UUID: The UUID from the configuration file.
- AlterId:
64. - Network:
tcp(orwsif using WebSocket).
- Connect and verify functionality.
-
Check Logs:
sudo journalctl -u v2ray
-
Verify Port Accessibility:
sudo netstat -tuln | grep 12345 -
Nginx Errors:
sudo tail -f /var/log/nginx/error.log
You now have a functional VMESS server running on Ubuntu! 🎉