My desired setup:
request → cloudflare (port forwarding with worker) → dreamhost dns record resolve with port set
My setup is:
- local webserver on port 8731
- private router which forwards 8731
- domain (yyy.xxx) on dreamhost
- cloudflare worker to forward all request to port 8731:
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
url.port = "8731";
return fetch(url, request);
},
};
I don’t have any DNS records set on cloudflare since I cannot apply the worker on domain root (yyy.xxx) and apply an additional record on the root. Thus the worker is my only config on cloudflare.
When I set my DNS servers to dreamhost only and set port 8731 manually in a request it works correctly. But when I want to add port forwarding by cloudflare and set therefore the cloudflare DNS servers with the worker on domain root (yyy.xxx) I get HTTP error 522.
When I traceroute my domain (yyy.xxx) I see the last server is a cloudflare server (104.21.51.193). Thus my request/response from my worker is not forwarded to dreamhost but I cannot figure out why.
Can anyone help me with this issue?