Part 3, the noob guide on 3x-ui setup for Vless proxy services with CDN
Continuing from my previous 3x-ui installation guide.
Creating Vless Proxy Inbounds with Cloudflare CDN
To Use Cloudflare CDN, you must do the following:
- You have to own a domain name, you don't have to buy from Cloudflare.
- But Cloudflare must control domain name servers(DNS) for your domain name.
- If Cloudflare is not the registrar for your domain name, you must create or already have an account at Cloudflare.
- From the Cloudflare Dashboard, click on the
Domainsmenu on the left side. - Click on the
[Add Domain]button on top right. - Select
[Connect a domain], put your domain name, and click[Continue]. - Select
FreePlan and it should try to import your existing DNS record. - Select
Continue Activationand just follow Cloudflare instructions on what to at the registrar that controls your domain name.
- From the Cloudflare Dashboard, click on the
- Go to the next step, if your domain is either registered or under control of Cloudflare.
- If Cloudflare is not the registrar for your domain name, you must create or already have an account at Cloudflare.
You will need 2 hostnames with the same IP address from your VPS. Because that one will be proxied through Cloudflare with access to only 1 port number used for proxy traffic and the Cloudflare CDN server will provide a different IP address for the proxied hostname. Because of these, you won't be able access the VPS for 3x-ui nor the other proxy inbound.
Create Another Hostname Record for VPS.
- Click on your domain name in the
Domainsmenu of the Cloudflare Dashboard. - Click on
DNS Recordson the right side and will see a list of DNS records or might be empty, if you haven't created any. - Click on
[+Add Record]button.- You should have already added an A record for your VPS. For example, lax1.example.com for 172.25.251.186 with the
Proxy StatusDNS Only. - Add another A record just for Cloudflare CDN. For example, lax1a.example.com for IPv4 172.25.251.186 with
Proxy StatusProxied.
- You should have already added an A record for your VPS. For example, lax1.example.com for 172.25.251.186 with the
- Click to expand
SSL/TLSmenu on the left panel and click onOverviewsub-menu. - Click on the
[Configure]button on the top of the right panel. - Select the Flexible for the SSL/TLS setting for the domain and click on the
[Save]button. - Under the
SSL/TLSmenu on the left panel, select theEdge Certificatessub-menu. - Scroll down to the
TLS 1.3setting and disable it. - Have the Cloudflare Dash page open for now, will get back it after a new inbound has been created.
Create a Vless/XHTTP/RAW security Inbound
This setup will ensure the traffic between your VPS and Cloudflare will not be double encrypted, it will have the encryption from any secure website you are connected to and also will be double encrypted between your proxy client and Cloudflare CDN. It's from the Flexible SSL/TLS from above. There are guides out there on using Full SSL/TLS, but I see all them require one to setup and run Nginx web server on the VPS. So I might write a guide on that that works with XHTTP and Nginx or another web proxy server, if I can get a setup that works.
- From the 3x-ui web control panel, select the
Inboundsmenu on the left panel and click on the[+Add Inbound]button in the main panel. - On the
Basictab, give a name for the inbound in theRemarkfield. - Leave the
Protocolfield from default vless. - Leave all the other fields the default, including the random
Portnumber. Write down or copy the random port number to the clipboard. DO NOT change it to 443 nor 8443. - Leave the rest of fields default on their settings and click on the
Streamtab and select XHTTP for theTransportsetting. - Click on the
[Create]button on the bottom. Go back to Cloudflare Dash page
Finishing Cloudflare CDN Setting
- Back to Cloudflare Dashboard, click on the
Networkmenu for your domain name'sDNS Record. - Enable the gRPC setting.
- Click on the
Rulesmenu and then theOverviewsub-menu. - In the
Origin Rulessection, click on the[Create Rule]button . - For
Rule Name, call it proxied hostname lax1a.example.com. As you need a different name rule for a different VPS. - Leave the default
Custom filter expressionand select Hostname forField. - Select Equal for
Operatorand enter you proxied hostname, ie lax1a.example.com, forValue. - For
Destination, selectRewrite, and enter the port number from the above vless inbound setting. - Click on the
[Deploy]button and we're done with the Cloudflare setup.
Once you import client config into your computer/smartphone proxy client app/program, you need to change some configs on it. Else it won't work correctly with Cloudflare CDN.
Create a Client and export to App for Vless Inbound
Follow the previous guide on client creation and import the client setting to a proxy client app/program
Change the Settings on Your Proxy Client App
After importing vless client config in the proxy client app, depending on the app, either right mouse click and select Edit or just left double clicking the vless config that was imported.
- Change the
addressfrom lax1.example.com to lax1a.example.com of proxied hostname. - Change
port numberto 443. - The
hostfield might empty, put in lax1.example.com. - The
TLSmight be empty or set tononeorraw, change TLS - Again put in proxied hostname lax1a.example.com in the
SNIfield. - Save the changes and you should be able to connect to the proxy server with the client app.
Conclusion on 3x-ui Setup
My final thoughts on the three 3x-ui from using it while behind the GFW are the following:
-
Hysteria2 is my primary proxy inbound I'm using in China, it has the fastest transfer that I used including NaïveProxy(3x-ui doesn't support it) and the multiple vless protocols. This is great for streaming video from YouTube, Netflix, HBO Max, Apple TV, and/or Amazon. If you're planning to use only Hysteria, set it use port 443. Else use 8443 and enable the port hopping feature. For comparison, I'm getting 5.22MiB/s download rate on one of my LAX VPS servers with ping latency ~180ms.
-
Vless with XHTTP and Reality combo is the best, if you are not planning to watch streaming video outside of China. But it is a more secure proxy protocol for browsing non-video websites. I'm getting .22MiB/s on the same VPS with the same latency.
-
Vless with XHTTP and Cloudflare CDN will be the least consistent for data transfer rate of the 3 for me. There are multiple reasons for this.
- Data traffic from a website has to first go to your VPS/proxy server, then relay through a Cloudflare CDN server near your VPS, and then finally to you behind the GFW.
- Unless you're paying for premium Cloudflare CDN, you won't get a CDN server in China. So you might get a CND server either close to China or might be close to the VPS.
- While the free Cloudflare CDN will allow a burst of high bandwidth for a static website, it may not continuously allocate high bandwidth for streaming video and such.
Experiment with multiple proxy client apps/programs. Because of the proxy engine that they’re using, some protocols’ data transfer suffer when comparing one client to another one. I have my OpenWrt setup that automatically switches between multiple proxy servers, each with the above 3 proxy setups. I will write a guide for that setup sometime in the future.