Bobcares

Cloudflare Tunnel Proxmox | Setup Steps

by | Nov 13, 2022

This post describes the steps to set up Cloudflare Tunnel with Proxmox. Bobcares, as a part of our Proxmox Support Services, offers solutions to every query that comes our way.

Set up Cloudflare Tunnel with Proxmox

The steps to set up Cloudflare Tunnel using Proxmox are as follows:

  • Cloudflared installation
  • Config.yml file creation
  • CNAME request creation
  • Tunnel execution
  • Cloudflare access config
  • Spice config

cloudflare tunnel proxmox

Let’s look into the details of each step.

Cloudflared installation

1. First, we must connect to the Proxmox server via SSH and download the Cloudflared deb package.

wget -q https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb && dpkg -i cloudflared-linux-amd64.deb

2. Then we will log in using the account.

cloudflared tunnel login

3. When we run this command, we will be given a link that we must copy and paste into the web browser. Now we must create a tunnel.

cloudflared tunnel create <NAME>

4. Then we must also save the generated UUID as we need it later. We can also select the name of our choice for the tunnel.

Config.yml file creation

1. In order to create a config.yml file, we can use the below code:

nano ~/.cloudflared/config.yml

2. This file will most likely be blank, so we need to set it up manually. Then we must add the blow and replace the sections in <> without the brackets.

tunnel: <UUID>
credentials-file: /root/.cloudflared/<UUID>.json

ingress:
- hostname: <domain>
service: https://localhost:8006
originRequest:
disableChunkedEncoding: true
noTLSVerify: true
- service: http_status:404

CNAME request creation

Now we’ve to create a CNAME request for the tunnel using the below code:

cloudflared tunnel route dns <UUID> <hostname>

Tunnel execution

In order to run the Tunnel, use the below code:

cloudflared tunnel run <UUID>

Cloudflare access config

Cloudflare access is great for creating an identity control process to allow access, but what prevents someone from simply finding the public IP address and entering it directly into the browser? To address this, we can create firewall rules that restrict access to only the Cloudflare IP ranges.

The best way to do this is to use the blocks in the router firewall. However, this needs a more advanced router than a standard SOHO router. We should block all inbound traffic from everything and then allow only Cloudflare IPs.

Spice config

This is a completely optional step. Everything should be fine up to this point. We should be able to use the admin page, start/stop/create VMs, and load a VM via noVNC. However, we will not be able to use SPICE over the internet. Connecting to the internal IP address will still work, but connecting to SPICE via the internet will fail.

We can fix this by changing the SPICE port in the Proxmox config files to something Cloudflare will proxy, such as port 8880. We must also modify the TLS auth-port so that SPICE can create a secure connection. If we want to do this, we must change the following files and lines:

/usr/share/perl5/PVE/HTTPServer.pm: my $remport = $remip ? 3128 : $spiceport;
/usr/share/perl5/PVE/AccessControl.pm: proxy => "http://$proxy:3128",
/usr/share/perl5/PVE/Service/spiceproxy.pm: my $socket = $self->create_reusable_socket(3128, undef, $family);
/usr/share/perl5/PVE/Service/spiceproxy.pm:SPICE proxy server for Proxmox VE. Listens on port 3128.
/usr/share/perl5/PVE/API2Tools.pm: my $port = $uri->port || 3128;

Although the SPICE connection is encrypted, the initial connection attempt is not.

[Looking for a solution to another query? We are just a click away.]

Conclusion

The article provides the steps to set up Cloudflare Tunnel with Proxmox, along with the SPICE configuration.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF