Direct domain to ip:port

I’m trying to redirect *.domain.com to my ipaddress:port, rather than to the default ipaddress:443, where port is one of the HTTPS ports listed here like 2083.

This is because I cannot forward port 443 on my router, as it is blocked by my ISP.
It says here that port does not need to be specified, but *.domain.com is not working for me, *.domain.com:port is working.

Also, I have tried using the recommended app Portzilla multiple times, but the worker does not start due to some error.

Hoping someone can shed some light on this one for me.

Try creating your own worker:

async function changePort(request) {
  var newURL = new URL(request.url)
  newURL.port = '2096'

  return fetch(newURL, request)
}
1 Like

Thanks for that. Unfortunately, I’ve never done any work with workers before.
Would deploying the following in a worker work ?

async function changePort(request) {
  var newURL = new URL(request.url)
  newURL.port = '2091'

  return fetch(newURL, request)
}

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

That should do it. Save that as a Worker, then create a Route for that domain to match example.com/* (or with the www in front if that’s what you use), and assign the script to that route.

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