jackbrycesmith / laravel-caprover-template

Template to deploy a Laravel app in docker for CapRover
MIT License
126 stars 42 forks source link

Websocket not working #19

Closed ezra-obiwale closed 2 years ago

ezra-obiwale commented 2 years ago

Hey, thanks for the template. Very nicely done.

I followed your websocket instructions and clients can connect on port 443, it seems this only connects to caprover but not the laravel app.

I mean, php artisan websocket:serve uses port 6001 yet we connect port 443.

Looking at the nginx config has set $upstream http://<%-s.localDomain%>:<%-s.containerHttpPort%>; where containerHttpPort is 80.

So please, what's the proper way to get this working? Thanks

jackbrycesmith commented 2 years ago

Hey sorry for missing this!

If you haven't already worked it out, all you need to do is check "Websocket Support" in the caprover app HTTP settings.

The caddy server gets all http requests & websocket connections coming through on the container port 80.

Then the following lines make it detect the websocket connections & send them to the websocket server on port 6001:

https://github.com/jackbrycesmith/laravel-caprover-template/blob/29dfcd0d7042b33a12f065893951ec4332410188/.deploy/config/Caddyfile#L4-L10

Untitled-2022-02-06-2310

ezra-obiwale commented 2 years ago

@jackbrycesmith Thanks for your reply. Unfortunately, the issue isn't resolved.

I have echo on the frontend caprover app trying to connect on port 443 to the websocket. The websocket dashboard shows that the frontend is connected but all subscriptions don't work.

Mind you, I'm able to connect directly to port 6001 locally which makes everything work smoothly however it's a different story with Caprover.