dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
6.32k stars 200 forks source link

Ngrok is giving blank page when https://localhost:443 works perfectly #816

Open milkeshaa opened 1 month ago

milkeshaa commented 1 month ago

Describe you feature request

When using ngrok with the basic/default setup of Franken server on docker everything works locally (i.e. https://localhost works as expected), but created by ngrok https URL gives an empty blank page.

ngrok http https://localhost gives created by ngrok https URL which leads to always blank page, but I expect it to lead to my local machine the same way as https://localhost:443 does.

So not sure if I'm missing something and didn't setup the local env properly, or franken package needs to be updated in some way to handle this functionality somehow.

I would expect ngrok generated URL to work the same way as localhost works.

withinboredom commented 1 month ago

I suspect this might be due to a fairly common misconception in software where someone hardcoded 127.0.0.1 as localhost instead of doing a DNS lookup for localhost which usually returns 127.0.0.1 for ipv4 and ::1 for ipv6. These are two separate addresses with the same hostname.

So, most likely, with the limited details I have at hand, ngrok likely doesn't know how to route to FrankenPHP because one is listening on 127.0.0.1 and the other is trying to connect to ::1 (or vice-versa). One way to fix this is to make sure localhost is defined as exactly one of these addresses in your /etc/hosts file and/or define the exact address using the SERVER_NAME environment variable when starting FrankenPHP:

SERVER_NAME=https://127.0.0.1 frankenphp ...