Xray Vmess + TLS + WS with Self-Signed Certificate
Xray is a fork of V2Ray. By following this post, you can create an Xray Vmess + TLS + WebSocket server without having to buy a domain name.
The server in this post runs Debian 11, and the client runs Windows 11.
Install Nginx on Server
1 | apt install nginx |
Create Self-Signed Certificate
Create a directory to hold your certificate:
1 | mkdir /etc/openssl |
Change into the directory that will hold your certificate:
1 | cd /etc/openssl |
Generate a private key for your certificate:
1 | openssl ecparam -out example.com.key -name secp384r1 -genkey |
Generate a certificate signing request:
1 | openssl req -new -sha256 -key example.com.key -out example.com.csr |
Enter anything you like for Country Name, State or Province Name, Locality Name, Organization Name, and Organizational Unit Name. For example:
1 | Country Name (2 letter code) [AU]: |
For Common Name, put example.com
.
Leave Email Address blank.
Leave the ‘extra’ attributes (challenge password and company name) blank.
Sign the certificate signing request, creating your certificate:
1 | openssl x509 -req -sha256 -days 365 -in example.com.csr -signkey example.com.key -out example.com.crt |
Make the server private key readable:
1 | chmod +r example.com.key |
Configure Nginx
Generate Diffie-Hellman parameters:
1 | openssl dhparam -out /etc/nginx/dhparam 2048; |
This may take a long time.
Edit the Nginx default site:
1 | vi /etc/nginx/sites-available/default |
Delete the default contents, and enter contents as below:
1 | server { |
Change /abcdefgh
to a secret path of your choice.
Save the configuration file.
Restart Nginx:
1 | systemctl restart nginx |
Install V2Ray on Server
Change back to the home directory:
1 | cd ~ |
Download the installation script:
1 | wget https://raw.githubusercontent.com/XTLS/Xray-install/main/install-release.sh |
Make the install script executable:
1 | chmod +x install-release.sh |
Run the installer:
1 | ./install-release.sh |
Configure V2Ray on Server
Edit the configuration file:
1 | vi /usr/local/etc/xray/config.json |
Delete existing contents and insert as follows:
1 | { |
Change /abcdefgh
to the secret path of your choice that you configured Nginx to use.
Change abe98b93-bd82-432f-8a41-0328a8aa5f5a
to the UUID of your choice.
Save the file with your edits.
Restart V2Ray on Server
1 | systemctl restart xray |
End work on server:
1 | exit |
Download V2Ray to Windows Client
Now work on your Windows PC that will be the client.
Open a browser and go to https://github.com/XTLS/Xray-core/releases.
Download the most recent release of Xray-windows-64.zip
.
Unzip Xray-windows-64.zip
.
Configure Xray on Windows Client
Copy and paste the configuration below into Windows Notepad:
1 | { |
Replace 123.45.67.89
by your server IP address.
Change /abcdefgh
to the secret path of your choice that you configured Nginx to use.
Change abe98b93-bd82-432f-8a41-0328a8aa5f5a
to the UUID of your choice.
Save this in a file named config.json
(with no .txt
on the end) in the same folder as the Xray application, Downloads\Xray-windows-64
.
Close Notepad.
Connect Windows Client to Server
Open the Windows Run box with Win+r, type cmd
, and click OK. This opens a Windows Command Prompt.
Change into the Xray directory:
1 | cd Downloads\Xray-windows-64 |
Run Xray with your configuration file:
1 | xray.exe -c config.json |
If Windows Defender Firewall intervenes, click Allow access.
Install Firefox Browser
If you do not already have Firefox installed, install Firefox now from https://www.mozilla.org/en-US/firefox/new.
Configure Firefox Browser
In Settings, under Network Settings, configure Firefox to use a SOCKSv5 proxy server at IP address 127.0.0.1
, port 1080
. Check the box to proxy DNS requests when using SOCKS v5.
Test Windows Client to Server Connection
In Firefox, visit https://whatismyipaddress.com.
You should see the IP address and location of your server, not your client.