V2ray

How To Setup V2ray Proxy Server With A VPS

Welcome to “How To Setup V2ray Proxy Server With A VPS” In this blog, we will provide complete information on mastering V2Ray, an effective open-source network proxy tool. Whether you are new to V2Ray or in search of to enhance your skills, this walkthrough will equip you with the information to effectively set up and optimize V2Ray on a Virtual Private Server (VPS).

V2Ray, famous for its flexibility and robustness, permits you to bypass network restrictions, enhance privacy, and invulnerable your online communications. However, putting up and configuring V2Ray on a VPS might also appear challenging to beginners. That’s where this blog comes in. We will guide you via every step, from selecting a VPS provider and setting up a connection to installing V2Ray, configuring each server and client settings, and optimizing its overall performance.

Choosing the right VPS (Virtual Private Server) is crucial when setting up V2Ray. the chosen VPS must have good:

  • Performance and Reliability: The performance and reliability of your VPS directly impact the overall performance of V2Ray. A high-quality VPS with robust hardware, sufficient resources (CPU, RAM, and storage), and a stable network connection ensure smooth and responsive V2Ray operations.
  • Location and Geo-Restrictions: The geographical location of your VPS affects the accessibility and bypassing of geo-restricted content. If you require V2Ray to access content from specific regions or to bypass censorship, selecting a VPS located in a suitable location can significantly enhance your ability to overcome such restrictions.

  • Network Speed and Latency: V2Ray heavily relies on network speed and latency to deliver fast and efficient proxy services. Selecting a VPS provider with good network infrastructure and low latency helps minimize delays and ensures optimal communication between V2Ray clients and the server.

  • Scalability and Flexibility: Your VPS provider should offer scalability options to accommodate your future needs. As your V2Ray usage grows, you may require additional resources or the ability to scale up your VPS plan. Choosing a provider that offers easy scalability ensures seamless expansion without disruptions.

  • Support and Assistance: A reputable VPS provider offers reliable customer support and assistance. When encountering technical difficulties or requiring guidance during the V2Ray setup, having access to responsive support can save time and ensure a smoother installation process.

It took some time but I was able to make a list of the best VPS to choose from

Check out: Top 10 best free VPS providers

  • FOR THIS TUTORIAL I HAVE CHOSEN ORACLE CLOUD AS MY VPS

step 2: Create a VM on your VPS

It doesn’t matter which VPS you have chosen just make sure that when you create your VM you do the following.

  • On Image: change it to Ubuntu 22.04 or lower versions
  • Size: any size greater/equal to 1GB ram should be enough, depending on what you will use the V2ray for.
V2ray

Fill in the rest of the required information and create your VM.

  • NOTE: in some VPS including Oracle Cloud you might need to first manually open ports after creating your VM. Click the link below to open the required ports.

Step 3: Buy a domain name

When looking to buy a cheap domain name, there are several reputable websites you can consider:

It’s important to note that while price is a consideration, it’s also essential to choose a reputable registrar with good customer support and reliable service. Take the time to compare prices, features, and customer reviews to ensure you select the best option for your needs.

Step 4: Point your domain DNS to cloudfare

follow the tutorial link below to Point your domain DNS to Cloudflare: How to add a domain on Cloudflare 

Step 5: Log in to your V2ray server using an SSH client the client

log in to your V2 Ray server using an SSH client the client that I usually go for is called Putty.

Once you have downloaded and installed Putty open it.

V2ray

once you’ve got Putty open you’ll need to enter the hostname or IP address of our V2 Ray proxy server to do this we’ll need to open back up our browser go to our VPS provider Tab and then copy the IP address of our server. paste it on host name and click open.

if you are using oracle cloud follow:

Install putty on the search for putty gen on your Windows search bar, open putty gen.

  • select load, and browse to where you have saved your private key.
  • click putty private key files and change it by selecting all files ” to make your file visible”
  • select your file and click on generate.
  • move your mouse over the blank area to generate.
  • select save private key, browse to where you want to save it, give it a name, and save it.
V2ray

Now search for putty and open it.

create a WordPress website with oracle cloud free tier
  1. on Host Name (or IP address): write ubuntu@” put your IP address at the end” as shown in the image above.
  2. select the + sign on SSH
  3. select Auth
create a WordPress website with oracle cloud free tier
  • Select browse and go to where you have saved your new private key” the one created on putty gen” and select it.
  • select session on the top left corner of Putty and under saved session write any name and save “so that you won’t have to do the process again next time”.
  • click open

Step 6: installing V2ray on your vps

To activate root type:

sudo-i

update your server:

apt-get update

Once our server has been updated the next thing we need to do is to download and install the V2 Ray proxy server onto our VPS do this with the following command  

bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)

The next thing we need to do is enable V2ray do this with the following command

systemctl enable v2ray

Start V2ray with

systemctl start v2ray

Check you V2ray status

systemctl status v2ray

It must be like this:

V2ray

navigate to the V2ray folder using the following command

cd /usr/local/etc/v2ray

now we need to open the JSON and edit it, we will use nano to open it so type:

nano config.json

delete everything there

V2ray

Click the link below to generate a UUID that we are going to use bellow

V2ray

copy your UUID and copy the following, then paste it on your notepad

{
"inbounds": [
{
"port": 10000,
"listen":"127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "86230575-318c-47e2-9d7d-a26c4b9733c1",
"alterId": 0
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/v2ray"
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}

replace the current UUID with the one you generated on the website, as shown in the image below

V2ray

copy all the edited text and paste it on Putty by right-clicking on your mouse

V2ray

now what we’ll need to do is save the changes that we have just made to the config. type Ctrl+O on your keyboard it will then ask you to name your file you must leave it as config.json and then hit enter on your keyboard great so the changes you have just made to your file have been saved now what we need to do is exit the Nano text editor by pressing Ctrl+X on your keyboard.

to go back to our root directory type CD and enter

next thing we need to do is set up our nginx web server to do this type:

apt-get install nginx -y

we need to type the command to get our lets encrypt SSL certificate to do this type the following command:

apt-get install certbot python3-certbot-nginx

you’ll be asked to enter your email address which as you can see says used for Urgent renewal and security notices so I’m just going to enter my email address now once you’ve entered your email address hit enter on your keyboard.

you’ll then be asked to read the terms of service if you agree to those terms please read the terms of service I’m going to press Y and then hit enter you’ll then be asked if you would like to share your email address with the Electronic Frontier Foundation which is a partner of let’s encrypt and cert box I’m going to type n for now hit enter on my keyboard.

V2ray

you’ll be asked to enter the domain names you would like on your certificate this is where we enter the domain name we purchased before, type it and click enter

 if successful you should see the message which says successfully deployed certificate 4 and then your domain name congratulations you have successfully enabled.

now got our SSL certificate we can check the certificate if it has indeed been issued by opening up our browser and opening up a fresh Tab and then go to your domain: it must be like this 

V2ray

go back to Putty the next thing we need to do is set up our Nginx configuration file to do this you’ll need to navigate to the file by typing in the following command:

cd /etc/nginx/sites-available

now type ls and click enter, then you will see a file called default this time instead of opening up our file using a text editor we’re actually going to delete it. type:

rm default

now recreate the file by typing: nano default and then click enter

copy the following and replace domain.com with your domain name:

server {
listen 80;
server_name domain.com;
return 301 https://domain.com$request_uri;
}

server {
listen 443 ssl;
server_name domain.com;

ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;

include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

location / {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
}

location /v2ray {
if ($http_upgrade != "websocket") {
return 404;
}
proxy_redirect off;
proxy_pass http://127.0.0.1:10000;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;

# Show real IP in v2ray access.log
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

replace just the highlighted parts as shown in the image below 

V2ray

now select Ctrl+A to select the whole thing and paste it back on Putty by right-clicking on your mouse.

  • now what we’ll need to do is save the changes we have just made to this default file to do this press Ctrl+O enter on your keyboard and Ctrl+X to exit out of the terminal.
Now what we need to do is go back to our root directory so type CD to change directory once you’re back in your root directory. and to restart nginx and v2ray type the following commands (click enter after every command).
systemctl restart nginx
systemctl status v2ray

close putty and now what we need to do is install the V2 Ray client so that we can connect to our server to do this open up your browser and click here

  • Navigate to assets and the one for your operating system and download it.
V2ray

install the downloaded software don’t open it yet, just download the v2ray core using this link

  1. unzip the downloaded folder 
  2. on your desktop create a new document, on the document past the following
{
"inbounds": [
{
"port": 1080,
"listen": "127.0.0.1",
"protocol": "socks",
"sniffing": {
"enabled": true,
"destOverride": ["http", "tls"]
},
"settings": {
"auth": "noauth",
"udp": false
}
}
],
"outbounds": [
{
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "domain.com",
"port": 443,
"users": [
{
"id": "0446e7c7-b95d-45f8-a813-8fd9426cbe4e",
"alterId": 0
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"wsSettings": {
"path": "/v2ray"
}
}
}
]
}

replace domain.com and UUID with your domain and UUID respectively replace the UUID with the one you generated before on the website.

V2ray

now save and rename the document as v2ray.json as show in the image below

V2ray

now open the Qv2ray software you have previously installed.

click on preferences and then click on kernel settings in the kernel settings you will need to select two file path locations the first one is for the V2Ray core executable path and the VRay assets directory for the V2Ray core executable path to the right-hand side of it click on select.

V2ray

navigate your desktop and look for your v2ray dash Windows that’s 64. the folder that you extracted from the zip file double click on it to go into it and then select the V2 Ray executable file which is the dot exe.

V2ray
  • Click OK
  • to import the v2ray.json file the one you saved on your desktop click on import click on Advanced and for the path click on select
V2ray

locate the v2ray.json file on your desktop and click on it. the click import

to connect to the server right click on the v2ray.json and click on the play icon as shown in the image below