I’ve configured a Symfony app to use Caddy installed through Docker.
To configure the Docker environment I used the Symfony Docker config by Dunglas.
When I connect to mywebsite.localhost I can see the page.
Now, I start a tunnel through ngrok with this command:
ngrok http https://myapp.localhost --host-header=rewrite
Once the tunnel starts, if I try to go to the generated tunnel , I get this error:
ERR_NGROK_8012
Traffic was successfully tunneled to the ngrok agent, but the agent failed to establish a connection to the upstream web service at myapp.localhost:443. The error encountered was:
dial tcp: lookup myapp.localhost: no such host
If I click on the link to my local app in the error (“myapp.localhost:443”), the page only reports this:
Client sent an HTTP request to an HTTPS server.
But if I go to https://myapp.localhost
, the app works as expected.
I supposed the problem was with the scheme (“http” instead of “https”), so I added --scheme=https
to the command, running this:
ngrok http https://olympus.localhost --host-header=rewrite --scheme=https
Also adding the explicit scheme configuration, I continue to receive the errors mentioned above.
My Caddyfile
is as follows:
{
# Debug
{$CADDY_DEBUG}
}
{$SERVER_NAME}
{$CADDY_EXTRA_CONFIG}
log
route {
root * /srv/app/public
mercure {
# Transport to use (default to Bolt)
transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
# Publisher JWT key
publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
# Subscriber JWT key
subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
# Allow anonymous subscribers (double-check that it's what you want)
anonymous
# Enable the subscription API (double-check that it's what you want)
subscriptions
# Extra directives
{$MERCURE_EXTRA_DIRECTIVES}
}
vulcain
push
php_fastcgi unix//var/run/php/php-fpm.sock
encode zstd gzip
file_server
}
As you can see, nothing complex nor “strange”.
Any ideas about why the tunnel created with ngork cannot correctly route requests to Caddy and my app?
PS
If you need further information, please, feel free to ask me them and I will add them ASAP!
Thank you