Specific server providers setups ‐ Cloudflare - MarechJ/hll_rcon_tool GitHub Wiki

🧭 You are here : Wiki home / Additional Setup / Specific server providers setups / Cloudflare


Setting up Cloudflare's cloudflared

The following guide will help you setup Cloudflare's Zero Trust application service tunnel called cloudflared. Typically this is used to secure internal applications using the Zero Trust authentication system, of which you can utilize Google/Microsoft authentication.

Another reason is to expose your applications from within your home network where your service provider might block port 80/443.

1. Sign up for Cloudflare

You'll need a Cloudflare account, and you will also need a domain name setup on Cloudflare.

Ensure you have access Zero Trust section so that it's setup in your account.

2. Create compose.override.yaml and add cloudflared to it

The cloudflared service needs to be configured in your compose.override.yaml file.

networks:
  tunnel:

services:
  tunnel:
    image: cloudflare/cloudflared
    restart: always
    command: tunnel run
    environment:
      - TUNNEL_TOKEN=${CLOUDFLARED_TUNNEL_TOKEN}
    networks:
      tunnel:

  ########### SERVER 1  #############
  backend_1:
    environment:
      - RCONWEB_PORT
      - PUBLIC_STATS_PORT
      - PUBLIC_STATS_PORT_HTTPS
  frontend_1:
    ports: !reset
    networks:
      tunnel:

  ########### SERVER 2  #############
  backend_2:
    environment:
      - RCONWEB_PORT
      - PUBLIC_STATS_PORT
      - PUBLIC_STATS_PORT_HTTPS
  frontend_2:
    ports: !reset
    networks:
      tunnel:

  ########### SERVER 3  #############
  backend_3:
    environment:
      - RCONWEB_PORT
      - PUBLIC_STATS_PORT
      - PUBLIC_STATS_PORT_HTTPS
  frontend_3:
    ports: !reset
    networks:
      tunnel:

  ########### SERVER 4  #############
  backend_4:
    environment:
      - RCONWEB_PORT
      - PUBLIC_STATS_PORT
      - PUBLIC_STATS_PORT_HTTPS
  frontend_4:
    ports: !reset
    networks:
      tunnel:

  ########### SERVER 5  #############
  backend_5:
    environment:
      - RCONWEB_PORT
      - PUBLIC_STATS_PORT
      - PUBLIC_STATS_PORT_HTTPS
  frontend_5:
    ports: !reset
    networks:
      tunnel:

  ########### SERVER 6  #############
  backend_6:
    environment:
      - RCONWEB_PORT
      - PUBLIC_STATS_PORT
      - PUBLIC_STATS_PORT_HTTPS
  frontend_6:
    ports: !reset
    networks:
      tunnel:

  ########### SERVER 7  #############
  backend_7:
    environment:
      - RCONWEB_PORT
      - PUBLIC_STATS_PORT
      - PUBLIC_STATS_PORT_HTTPS
  frontend_7:
    ports: !reset
    networks:
      tunnel:

  ########### SERVER 8  #############
  backend_8:
    environment:
      - RCONWEB_PORT
      - PUBLIC_STATS_PORT
      - PUBLIC_STATS_PORT_HTTPS
  frontend_8:
    ports: !reset
    networks:
      tunnel:

  ########### SERVER 9  #############
  backend_9:
    environment:
      - RCONWEB_PORT
      - PUBLIC_STATS_PORT
      - PUBLIC_STATS_PORT_HTTPS
  frontend_9:
    ports: !reset
    networks:
      tunnel:

  ########### SERVER 10 #############
  backend_10:
    environment:
      - RCONWEB_PORT
      - PUBLIC_STATS_PORT
      - PUBLIC_STATS_PORT_HTTPS
  frontend_10:
    ports: !reset
    networks:
      tunnel:

Just like setting up the compose.yaml, delete the parts concerning servers you don't need.

⚠️ NOTE: This will turn off access from the normal ports since it stops exposing them

3. Make an nginx.conf with Real client IP configured for Cloudflare

  1. Copy the default-nginx.conf to nginx.conf for editing
cp config/default-nginx.conf config/nginx.conf
  1. Edit nginx.conf
nano config/nginx.conf
  1. Configure Real client IP for Cloudflare Uncomment (remove the #) the following lines and change the values to match:
set_real_ip_from     tunnel;            # container/service name/proxy IP/CIDR range
real_ip_header       CF-Connecting-IP;  # or CF-Connecting-IP behind Cloudflare's proxy

4. Edit your .env to have CLOUDFLARED_TUNNEL_TOKEN in it, doesn't matter where:

CLOUDFLARED_TUNNEL_TOKEN=

5. Configure Application on Cloudflare

⚠️ See setting up your domain on Cloudflare below if that is not done yet.

  • Head to https://dash.cloudflare.com/
  • Select the domain that is managed by Cloudflare that you want to use for the tunnel
  • Click on Networking>Tunnels on the left side
  • Then click on + Create Tunnel
  • Name your Tunnel
  • Click Create Tunnel
  • Copy the command that contains the tunnel token
  • Put just the token from the copied command after CLOUDFLARED_TUNNEL_TOKEN= in your .env with no spaces, its the long string at end of the command
  • Restart CRCON docker compose up -d
  • Click Continue
  • Click on your Tunnel name
  • Click Routes

For each game server [n] you have:

  • Click + Add route
  • Click Published application
  • Make a Subdomain name to access the private part of CRCON for your [n] game server from
  • Choose the Domain in Cloudflare to use
  • Set the Service URL to http://frontend_[n]:80 ie http://frontend_1:80 for the first game server
  • Click Add Route
  • Again click + Add route
  • Make a Subdomain name to access the public stats part of CRCON for your [n] game server from
  • Choose the Domain in Cloudflare to use
  • Set the Service URL to http://frontend_[n]:81 ie http://frontend_1:81 for the first game server
  • Click Add Route
  • Repeat for all of your game servers

Now you should be able to access CRCON from your chosen sub domains through Cloudflare

Setting up your domain on Cloudflare

There are a couple of options.

  1. Change your name servers at your domain registrar. This is the easiest if you already have a domain. Cloudflare will import your DNS records via a scan, and you can update any that were missed

  2. Transfer your domain to Cloudflare. This isn't required, but also works.

  3. Register a new domain. If you want a specific domain for your rcon, .com's are cheap. Just register a new one and you'll be ready to point the domain to your CRCON. This also works if you have multiple servers, you can still use sub-domains and keep your main domain clean of DNS records.