localhost, so nothing arrives on a
development machine until it has an address on the public internet.
A tunnel solves this: a small process holds an outbound connection to a public
endpoint, and traffic arriving there is forwarded to your local web server. No
port forwarding, no router configuration, no certificate of your own.
You only need this to receive real messages. Running the application, the
builder, the admin panels and the test suite needs no tunnel at all — see
Local setup.
A stable address
This is the arrangement worth having if you touch channels more than once. The hostname survives restarts, so.env stays valid and channels stay registered.
The quick way, where it works
cloudflared can also hand out a throwaway address with no account at all:
https://calm-oak-2187.trycloudflare.com, valid
until you stop the process. The address changes on every run, so each restart
means editing .env and re-registering channels — which is the reason to prefer
a named tunnel once you are past the first afternoon.
Pointing the application at it
Whatever the address, the application has to build its webhook URLs from it:Why the Host header is rewritten
The helper passes--http-host-header for a reason worth knowing if you write
your own command.
A local site is usually served by name — fapost-core.test — and the web server
picks which site to serve from the Host header. A tunnel forwards the public
hostname in that header, so the request arrives asking for
dev.example.com, which the local server does not recognise. The flag rewrites
it back to the name your vhost expects.
If you serve the application on a bare port instead, this does not arise.
Alternatives
Anything that gives a public HTTPS URL forwarding to a local port will do. ngrok is the other common choice and the repository carriestools/ngrok-http for it:
cloudflared is documented first.