Help setting up multiple tunnels on the same machine

Hey, i am having some trouble setting up multiple tunnels on the same machine. I would like to run 2 or more tunnels on one ubuntu machine.
13 Replies
Chaika
Chaika7mo ago
for what specific reason? You really shouldn't need to in 99% of cases, just add more public hostnames/routes the existing tunnel
Franky
FrankyOP7mo ago
I need multiple websites with different domain names
Hello, I’m Allie!
A single tunnel can point to multiple domains, as long as they are on the same account
Franky
FrankyOP7mo ago
I need to have 3 websites, 2 are on the same account, one is not But I am a collaborator
Hello, I’m Allie!
Do you have Docker on that machine?
Franky
FrankyOP7mo ago
No, I dont
Hello, I’m Allie!
You are able to run multiple tunnels together using TUNNEL_TOKEN=sometoken cloudflared tunnel run. The issue is that this won't persist across restarts You would need something to call this command for every tunnel you want on startup
Franky
FrankyOP7mo ago
that's a bit of a problem
Hello, I’m Allie!
cloudflared does have a service you can install. The reason that doesn't work though is that you can only have one installed at a time
Franky
FrankyOP7mo ago
you said that i could get multiple websites working with a single tunnel, i think i might ask my friend to trasnfer ownership or something that would work, right?
Hello, I’m Allie!
Yeah. As long as all of the domains are within your account, then you should be able to create a single tunnel that covers all of them Actually, just got someone to show me another way. Let me check it to be sure, then I'll share
Franky
FrankyOP7mo ago
thanks did you find it by any chance?
Hello, I’m Allie!
I have the setup, but I haven’t been able to get it to work myself, unfortunately Let me copy it over, then you can see if it works for you Create/replace the file /etc/systemd/system/[email protected] with
[Unit]
Description=cloudflared tunnel (%i)
Documentation=https://github.com/cloudflare/cloudflared
After=network.target

[Service]
LimitNOFILE=4096
PIDFile=/run/cloudflared-%i.pid
ExecStartPre=/usr/local/bin/cloudflared update
ExecStart=/usr/local/bin/cloudflared --config /etc/cloudflared/%i.yml tunnel --no-autoupdate run
Restart=on-failure
StartLimitInterval=10

[Install]
WantedBy=multi-user.target
[Unit]
Description=cloudflared tunnel (%i)
Documentation=https://github.com/cloudflare/cloudflared
After=network.target

[Service]
LimitNOFILE=4096
PIDFile=/run/cloudflared-%i.pid
ExecStartPre=/usr/local/bin/cloudflared update
ExecStart=/usr/local/bin/cloudflared --config /etc/cloudflared/%i.yml tunnel --no-autoupdate run
Restart=on-failure
StartLimitInterval=10

[Install]
WantedBy=multi-user.target
, then run systemctl daemon-reload. Place each config in /etc/cloudflared/, then start it with systemctl enable --now cloudflared@config-name
Want results from more Discord servers?
Add your server