Using single tunnel to hit multiple IoT devices

Hi,

I have a requirement/problem to solve and need a help from the community.

Scenario
I have multiple IoT devices and each has a web application hosted. I’d want to access the application over internet using a common URL. Lets say the URL is https://xyz.iot.com. Now, by mentioning different URL path, Is it possible to route the connection to the appropriate IoT deivce?

For example,

  1. https://xyz.iot.com/abcd → It should reach IoT device (abcd)
  2. https://xyz.iot.com/cfgh → It should reach IoT device (cfgh)

I tried creating a common tunnel using DNS record but couldn’t reach the devices according to the URL path. Tried ingress rules with URL path. It always goes to one IoT device.

Any help is much appreciated

I’m not sure how you’re expecting this to work. You can’t have the same tunnel for one hostname that goes to different devices based on a path. Tunnels aren’t much different from standard connections. They’re are based on hostnames, just like DNS.

It’d be better to build a Worker for xyz.iot.com that directs traffic to an internal hostname, such as abcd.iot.com, etc. The Worker can still send the same xyz.iot.com host header when it makes that connection, though.

1 Like

Each should have it’s own local IP address and each should have cloudflared tunnel installed and configured for separate hostname like device1.example.com, device2.example.com, etc. to which you could access over a Web browser as @sdayman already mentioned.

Due to my curiosity, may I ask which ones?
I do have a case with one client where we’re using IoT devices and web apps like Raspberry Pi, Arduino or even PLC devices connected to the local network, therefore all able to control and expose over cloudflared. Therefore, each has got it’s own hostname. So far working fine and secured with :orange: .

Thanks everyone for your comments.

Perhaps, if I explain why I wanted to have single tunnel connecting multiple IoT devices, I would be more clear for you guys.

Accessing them over dedicated hostnames has an limitation due to limited number of subdomains. I guess its just 500 subdomains cab be created. But in my case, I want to support more IoT devices like devices in a few thousands.

That’s why I was curoius to know if any solution is readily available that I could use it. Based on the comments, it seems that cloudflared Zero Trust doesn’t have a solution for this.

Is my understanding correct or do you guys think that it can be achived using other means?

If you don’t mind my asking, how do you connect with a PLC. I’d like to use an HMI app to connect with a PLC through secure tunnels.
the HMI app requires I use a port. ie/local IP of 192.168.1.101:44818

You can try to setup a proxy with nginx on the machine where the tunnel is installed and redirect to different ip address but this is only an idea.
I have tried with no success