Tunnel a Web Application Using Cloudflared

Configure the domain in Cloudflared

https://dash.cloudflare.com/

Download and install the client

Github

Install the certificate

cloudflared tunnel login

Create the tunnel

cloudflared tunnel create {name}

Modify the config.yml file

tunnel: {name}
credentials-file: /path/to/.cloudflared/{uuid}.json
ingress:
  - hostname: {hostname}
    service: http://127.0.0.1:{port}
  - service: http_status:404

Route the DNS (Remove from CNAME from cloudflared before)

cloudflared tunnel route dns {tunnel} {host}

Install the service (copy .cloudflared to /root/)

sudo cloudflared service install

Configure the Application as Service

[Unit]
Description={short description}
After=syslog.target network.target
[Service]
SuccessExitStatus=143
User={user}
Group={user}

Type=simple

ExecStart=/path/to/start.sh
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target
#!/bin/bash
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64
WORKDIR={}
cd $WORKDIR
$JAVA_HOME/bin/java -jar {jarname} {other parameters}

Tags linux sbc

Back