Setup Swoole Socket Server on PHP container

I’ll be using this package for my Laravel project.
It’s based on Swoole. when I start the Swoole, it listens on 127.0.0.1:5200 (For HTTP & Socket connections)

However, I’m having trouble configuring Nginx for Swoole (On a specific vhost or globally). (Check the link for required config)

I know I can customize web servers in my project (Official doc)
But in a config like this, I can’t wrap my head around it.
Note:

  • When I try to establish a ws connection on my vhost (e.g: ws://myproject.loc:8000) , it returns a 200 response, which means Nginx is not configured to handle these responses (http_upgrade for socket).
  • I want my HTTP requests to be handled by Laravel Swoole on port 5200.
  • My devilbox runs on port 8000.
1 Like