Making HTTP requests to IP address from Worker
I am trying to make HTTP requests from my Cloudflare Worker to a backend service that is only available via IP address (no domain name):
The same call works over CURL, but from my Worker I get a 1003 Error.
- I tried using
fetch
and get blocked
- I tried using Node's http module with nodejs_compat
and getting: [unenv] http.request is not implemented yet!"
- When I try to make the call directly from the Frontend (my html file), I get a mixed content error because my site is served over https but the backend is http.
Question: What's the recommended way to make HTTP requests to an IP address from a Worker when a domain name isn't available? Is there a way to bypass the IP address restriction, or should I be looking at a different architecture?
3 Replies
You can't directly fetch an IP Address from Workers, for security reasons
fetching insecure/plaintext http across the internet is a really bad idea anyway
Cloudflare Tunnels are an easy way to securely connect to an origin w/o configuring anything on the origin https wise, they're just a piece of software which runs on the origin server and connects securely back out to Cloudflare
https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel/
Cloudflare Docs
Create a tunnel (dashboard)
Follow this step-by-step guide to create your first remotely-managed tunnel using Zero Trust.
Thanks for clarifying that it isn't possible. I know it is not good practice but I'm looking into this for a demo/prototype and I currently don't have access to the server hosting the IP address. So I can't implement a tunnel there.