Direct domain to ip:and port

so I’m trying to redirect my domain to the web server I have at IP:2223

searching the community I fount an old post that say’s to use a worker to redirect the traffic with the following code

`async function changePort(request) {
var newURL = new URL(request.url)
newURL.port = ‘2223’

return fetch(newURL, request)
}

addEventListener(‘fetch’, async event => {
event.respondWith(changePort(event.request))
})`

it works and direct me to the index page however there is an error from cloudflare about the site being offline

and upon testing other URLs I receive the following error

I have a valid certificate I know that for a fact as this setup used to work using portzilla however I am looking for a free alternative

Workers are not necessarily free either, unless you stay within the free limit.

Are you sure your Worker is properly mapped? Can you post a screenshot of the mapping?

Sorry I’m very new to workers is this what your talking about when you say mapping?

Post a screenshot of https://dash.cloudflare.com/?to=/:account/:zone/workers

is this what your looking for?

That needs a wildcard if you want all URLs to call the script -> /*

Thank you

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