Redirection using workers

Hello,

I am trying to redirect a subdomain to a cloud hosted screenconnect server with a port. I reached out to support and they mentioned the best way to do this is with a worker. So I created the worker and it seems to show the correct page in the test but when I got to the subdomain it says server not found. Am I missing something? DO I need to create a DNS record? If so where does it point to?

If it’s a subdomain why not with a page rule to redirect there?

If you want to forward the queries and serve it as if you were hosting that website you need to create a record for that subdomain, ideally pointing to the correct server and them simply change the port via the worker. There is also an app in the Cloudflare Apps platform that does that.

I also tried a page rule but that didn’t seem to work unless it takes time to update. The reason for this is that it has to point to the FQDN with port because the servers ip address is dynamic. Do I need a DNS entry for page rules also? I set it up as forwarding url permanent redirect 301.

Yes, you need a record for everything. If it’s just a simple redirect even a bogus one, to one of the IPs like 192.0.2.1, would work. If you want the worker pointing directly at the origin, if possible is easier on the code.

1 Like

So I created an A record with a bogus IP for Help using the orange cloud. Do I need to give it some time to update? Sorry for all the questions I have never used advanced features like these. Thought this would be simple haha.

It should be pretty quick since it’s not already existent, time to update the records it’s usually close to zero or to their TTL (Cloudflare’s is 5 minutes).

That seemed to work. I updated my DNS to Cloudflare’s and the changes showed immediately. Thank you so much for the help!

1 Like