Websocket via xinetd an php Script:

apt install xinetd

in etc/xinetd.d eine Datei names weksocket mit folgenden Inhalt erstellen:

service websocket_php_service
{
  disable     = no
  socket_type = stream
  protocol    = tcp
  wait        = no
  user        = www-data
  server      = /usr/bin/php
  server_args = /pfad_zum_zu_startenden_script/script.php
  port        = 3000
}

systemctl restart xinetd

entsprechender Eintrag in der nginx.conf im Serverblock:

  location /ws {
      proxy_pass http://localhost:3000;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header Host $host;
  }