I’ve started to use Caddy with the ngrok.io tunnel server service (https://ngrok.io/) that allows a site running on localhost:8080 to be accessible from a custom URL.
I create the tunnel using:
ngrok http localhost:8080
The Caddy server is running on localhost and port 8080. These are the pertinent lines from my Caddyfile:
localhost:8080
However, when I try to connect using the URL given to me by the ngrok service, I get the following reply from Caddy when I try to access the web root:
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
Server: Caddy
X-Content-Type-Options: nosniff
Date: Tue, 28 Mar 2017 17:24:11 GMT
Content-Length: 21
No such site at :8080
What is going on here, and why can’t I access localhost using the webroot?
By the way, the same return code from the server (“No such site at :8080”) is also returned when I use the localtunnel.me service.
I am running Linux on my development machine (Linux Laura 4.4.0-67-generic #88-Ubuntu SMP Wed Mar 8 16:34:45 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux).
where [ip address] is my current IP address, but this did not work.
Could you clarify how I can remove the “localhost” from the site definition? I have also tried 127.0.0.1, but the same problem is apparent. That is, in my Caddyfile:
127.0.0.1:8080
This is the only line that I have in my file for the site definition. Is something else required?
When a client accesses Caddy via yourapp.ngrok.io, Caddy will look for server configuration for yourapp.ngrok.io, which it doesn’t have (because it was configured for localhost, then your IP address).
By changing the Caddyfile to :8080, Caddy will serve that configuration to any host, localhost, your IP, example.com, or ngrok.io, because it is essentially a wildcard host. In this case, using yourapp.ngrok.io:8080 would also work, but then you would get 404s if you tried to access it locally in the browser via localhost:8080.