Cloudflare Tunnels and .NET HttpListeners


I am having a strange issue, which most likely is a lack of skill on my part.

I have a cloudflare tunnel (in linux), pointing to http://localhost:5000.
This is being “heard” by an console app in .NET that has an HttpListener on http://localhost:5000

this._listener = new HttpListener() { };

If i use Curl on http://localhost:5000 I get a response and all looks good. If I use the tunnel I get a 404 from cloudflare

If I use a standard .NET web app (literally just creating it in Visual Studio and deploy/run it) on the same exact port, the tunnel works perfectly.

Does anyone have any idea on why this might be happening?


And the solution has been found
The issue was the HTTP Host headers

Since the HTTP Listener was listening on localhost it expects the HTTP Host header to match localhost

In my scenario, since I am using Cloudflare Tunnels, the simple solution is to make the prefix its listening to be to http://*:5000 instead of localhost and it worked perfectly

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