But frankenphp won’t start. The startup logs have this error message:
Aug 22 16:24:21 dev.sportch.co.uk frankenphp[1157]: Error: loading initial config: loading new config: http app module: start: listening on :5502: listen tcp :5502: bind: address already
in use
I should also just point out that what I’m trying to do is to migrate from a Caddy/PHP-FPM setup, to a FrankenPHP setup.
With the former. the chatserver listens on port 5502 and the caddy server doesn’t actually need to get involved in routing that traffic. So the Caddyfile on that server has no route for 5502 and no @websocket named matcher. In case it helps, here’s that Caddyfile:
However, on the frankenphp version, there seems to be some sort of disconnect that I haven’t been able to figure out, whereby the chatserver (which runs as a php app launched from the CLI via systemd but because frankenphp doesn’t provide a CLI it is therefor using a separate instance of PHP; I don’t know if that has an impact?) is not seeing traffic on that port. The traffic just seems to get swallowed up. I can see it coming in via tcpdump but it doesn’t seem to reach the listener.
What Matt was saying is that you were making requests to port 5502, but Caddy is listening on port 443. Make requests to port 443 (i.e. https://, you can omit the port) instead.
Ah, actually your problem is you put your reverse_proxy at the end of your route, so it never runs because php_server takes all requests and nothing goes past it. In route, the order you place directives matter. Move it above php_server. Your rewrites need to go earlier as well.
Though, you don’t need to be using route at all. Since v2.8.0, pretty sure FrankenPHP uses the new feature which allows plugins to set their own order for Caddyfile directives.
The 5502 bind errors you can revert back to the prior site address config to resolve, since as you’ve described you don’t want Caddy listening on 5502, you just want the chatserver there. Then implement Francis’ ordering advice.
It’s trying to connect directly to the upstream bypassing Caddy, but I’m guessing your upstream doesn’t have a valid certificate like Caddy does.
It seems to me like you need to configure your client to connect to Caddy instead, on wss://dev.sportch.co.uk/ (note no specified port implies default WSS port which is 443), so Caddy can present a valid certificate and then proxy to your upstream.
Ok. Sounds good. But how? (And why isn’t this an issue with caddy / php-fpm?).
P.S. I can’t change the ws port as that’s baked into the client as 5502. I don’t want to have to completely redeploy all our client software just to get the new server to work.
Keep in mind – all of this works flawlessly with caddy / php-fpm. So the big question is – why isn’t it working with frankenphp? Like what’s the difference?
If you need your clients to connect to Caddy on port 5502, then you’ll need to put Caddy on 5502, and you’ll need to shift your upstream somewhere else. You obviously can’t have them both listening on the same port, so something’s gotta give.
The only difference I’m aware of between Caddy+PHP-FPM and FrankenPHP is that the former proxies PHP script requests to a separate FPM listener, and the latter instead handles the request in-process with a Go-based PHP processor, no proxy. So as far as I’m concerned, if you took your current config and just stripped out FrankenPHP and swapped in PHP-FPM, I’d have to assume it would fail in the same manner.
So I have to admit I’m not sure what the difference is. I’m not familiar with your upstream myself, and I haven’t seen your working Caddy+PHP-FPM config to compare and contrast with what you’re trying to achieve with FrankenPHP.
omg… a colleague suggested restarting the chatserver service… and that worked. It had cached expired certs. I can’t believe that during all of that debugging, the one thing I obviously didn’t do, is restart the chatserver service.