Can't reach origin through Worker

My ISP blocks common ports (21, 80, 443…), so I’m trying to use a Worker as a simple reverse proxy to route from 80 and 443 to a port I can actually forward in my router.

Internally I have a Caddy instance reverse proxying the services to the correct ports. Accessing the service directly, from my mobile phone’s data connection, through domain:8921 works without issue but domain:80 and domain:443 never even reach my server even though I can ping the Worker URL.

From the Worker’s Quick Edit page, both the Http and Preview tab can reach my server but when I try to access any service from my mobile phone’s data connection I get a Connection Refused error, even though checking Caddy’s logs makes it clear it never even reached the server. Looks like a timeout.

Here’s the Worker code:

async function changePort(request) {
  var newURL = new URL(request.url)
  newURL.port = '8921'
  return fetch(newURL, request)
}

addEventListener('fetch', async event => {
  event.respondWith(changePort(event.request))
})

Any ideas?

Can’t edit, but here’s another tidbit, the Worker route is set up for *.domain

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.