From 20cb29c2f8c5c87bc590896854a20b1473ceb358 Mon Sep 17 00:00:00 2001 From: "info@mode42.com" Date: Sat, 8 Aug 2026 03:54:55 +0000 Subject: #2 --- share/reverse-proxy/README.txt | 6 ++ share/reverse-proxy/apache2.conf.example | 24 ++++++ share/reverse-proxy/docroot/README.txt | 7 ++ .../docroot/hybbx-websocket/hybbx-terminal.js | 95 ++++++++++++++++++++++ .../docroot/hybbx-websocket/index.php | 89 ++++++++++++++++++++ share/reverse-proxy/lighttpd.conf.example | 26 ++++++ share/reverse-proxy/nginx.conf.example | 28 +++++++ 7 files changed, 275 insertions(+) create mode 100644 share/reverse-proxy/README.txt create mode 100644 share/reverse-proxy/apache2.conf.example create mode 100644 share/reverse-proxy/docroot/README.txt create mode 100644 share/reverse-proxy/docroot/hybbx-websocket/hybbx-terminal.js create mode 100644 share/reverse-proxy/docroot/hybbx-websocket/index.php create mode 100644 share/reverse-proxy/lighttpd.conf.example create mode 100644 share/reverse-proxy/nginx.conf.example (limited to 'share/reverse-proxy') diff --git a/share/reverse-proxy/README.txt b/share/reverse-proxy/README.txt new file mode 100644 index 0000000..a11d1cc --- /dev/null +++ b/share/reverse-proxy/README.txt @@ -0,0 +1,6 @@ +HyBBX reverse-proxy examples. WebSocket plugin = session data on loopback only. + +1. HTTPD_DOCROOT=/srv/www # your httpd document root +2. cp -r docroot/hybbx-websocket $HTTPD_DOCROOT/ +3. Add nginx/apache/lighttpd snippet (adjust paths) +4. hybbx.ini [transport.websocket] — see docs/WEBSOCKET.md diff --git a/share/reverse-proxy/apache2.conf.example b/share/reverse-proxy/apache2.conf.example new file mode 100644 index 0000000..a361532 --- /dev/null +++ b/share/reverse-proxy/apache2.conf.example @@ -0,0 +1,24 @@ +# HyBBX — Apache httpd 2.4. HTTPD_DOCROOT example: /srv/www + + + ProxyPreserveHost On + ProxyTimeout 3600 + SSLProxyEngine On + SSLProxyVerify none + SSLProxyCheckPeerCN off + SSLProxyCheckPeerName off + + ProxyPass "/hybbx-websocket/ws" "wss://127.0.0.1:4591/hybbx" timeout=3600 keepalive=On + ProxyPassReverse "/hybbx-websocket/ws" "wss://127.0.0.1:4591/hybbx" + + +Alias /hybbx-websocket /srv/www/hybbx-websocket + + DirectoryIndex index.php + Require all granted + + SetHandler application/x-httpd-php + + + +# UI: cp -r reverse-proxy/docroot/hybbx-websocket $HTTPD_DOCROOT/ diff --git a/share/reverse-proxy/docroot/README.txt b/share/reverse-proxy/docroot/README.txt new file mode 100644 index 0000000..0c820fe --- /dev/null +++ b/share/reverse-proxy/docroot/README.txt @@ -0,0 +1,7 @@ +Copy docroot/hybbx-websocket/ to HTTPD_DOCROOT (not HYBBX_ROOT). +HyBBX websocket plugin ships session data only on loopback :4591. + + HTTPD_DOCROOT=/srv/www + cp -r docroot/hybbx-websocket $HTTPD_DOCROOT/ + +Match URL paths in hybbx.ini and the httpd snippets in docs/WEBSOCKET.md. diff --git a/share/reverse-proxy/docroot/hybbx-websocket/hybbx-terminal.js b/share/reverse-proxy/docroot/hybbx-websocket/hybbx-terminal.js new file mode 100644 index 0000000..50fb826 --- /dev/null +++ b/share/reverse-proxy/docroot/hybbx-websocket/hybbx-terminal.js @@ -0,0 +1,95 @@ +(function () { + 'use strict'; + + var term = document.getElementById('term'); + var status = document.getElementById('status'); + var form = document.getElementById('input-bar'); + var input = document.getElementById('cmd'); + var wsUrl = window.HYBBX_WS_URL; + var ws = null; + var reconnectTimer = null; + var reconnectDelayMs = 2000; + var reconnectAttempt = 0; + + function append(text) { + term.textContent += text; + term.scrollTop = term.scrollHeight; + } + + function setStatus(s) { + status.textContent = s; + } + + function scheduleReconnect() { + if (reconnectTimer) { + return; + } + + reconnectAttempt += 1; + setStatus('reconnecting in ' + (reconnectDelayMs / 1000) + 's'); + reconnectTimer = window.setTimeout(function () { + reconnectTimer = null; + connect(); + }, reconnectDelayMs); + } + + function setInputEnabled(enabled) { + input.disabled = !enabled; + if (enabled) { + input.focus(); + } + } + + function sendLine(text) { + if (!ws || ws.readyState !== WebSocket.OPEN) { + return; + } + + ws.send(text + '\r'); + } + + function connect() { + setStatus('connecting'); + setInputEnabled(false); + ws = new WebSocket(wsUrl); + + ws.onopen = function () { + reconnectAttempt = 0; + setStatus('connected'); + setInputEnabled(true); + }; + + ws.onmessage = function (ev) { + append(ev.data); + }; + + ws.onclose = function (ev) { + var reason = ev.reason ? ' (' + ev.reason + ')' : ''; + + append('\n[websocket disconnected: code ' + ev.code + reason + ']\n'); + setStatus('disconnected: ' + ev.code); + ws = null; + setInputEnabled(false); + scheduleReconnect(); + }; + + ws.onerror = function () { + setStatus('error'); + setInputEnabled(false); + }; + } + + form.addEventListener('submit', function (ev) { + ev.preventDefault(); + + if (!ws || ws.readyState !== WebSocket.OPEN) { + return; + } + + sendLine(input.value); + input.value = ''; + input.focus(); + }); + + connect(); +})(); diff --git a/share/reverse-proxy/docroot/hybbx-websocket/index.php b/share/reverse-proxy/docroot/hybbx-websocket/index.php new file mode 100644 index 0000000..52a060c --- /dev/null +++ b/share/reverse-proxy/docroot/hybbx-websocket/index.php @@ -0,0 +1,89 @@ + + + + + + HyBBX + + + +
disconnected
+

+  
+ +
+ + + + diff --git a/share/reverse-proxy/lighttpd.conf.example b/share/reverse-proxy/lighttpd.conf.example new file mode 100644 index 0000000..1ef9244 --- /dev/null +++ b/share/reverse-proxy/lighttpd.conf.example @@ -0,0 +1,26 @@ +# HyBBX — lighttpd 1.4. HTTPD_DOCROOT example: /srv/www + +# Raise idle limits for upgraded WebSocket connections. +server.max-read-idle = 3600 +server.max-write-idle = 3600 + +$HTTP["url"] == "/hybbx-websocket/ws" { + proxy.server = ( "" => ( + "hybbx" => ( + "proxy" => "https://127.0.0.1:4591/hybbx", + "upgrade" => "enable" + ) + )) + proxy.header = ( "upgrade" => "enable" ) +} + +alias.url += ( "/hybbx-websocket/" => "/srv/www/hybbx-websocket/" ) +index-file.names += ( "index.php" ) + +fastcgi.server += ( ".php" => + ( "localhost" => + ( "socket" => "/run/php-fpm/www.sock" ) + ) +) + +# UI: cp -r reverse-proxy/docroot/hybbx-websocket $HTTPD_DOCROOT/ diff --git a/share/reverse-proxy/nginx.conf.example b/share/reverse-proxy/nginx.conf.example new file mode 100644 index 0000000..c916379 --- /dev/null +++ b/share/reverse-proxy/nginx.conf.example @@ -0,0 +1,28 @@ +# HyBBX — nginx. Set HTTPD_DOCROOT (example: /srv/www). + +location = /hybbx-websocket/ws { + proxy_pass https://127.0.0.1:4591/hybbx; + proxy_ssl_verify off; + proxy_http_version 1.1; + proxy_socket_keepalive on; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_read_timeout 3600s; + proxy_send_timeout 3600s; +} + +location /hybbx-websocket/ { + root /srv/www; + index index.php; + location ~ \.php$ { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_pass unix:/run/php-fpm/www.sock; + } +} + +# UI: cp -r reverse-proxy/docroot/hybbx-websocket $HTTPD_DOCROOT/ +# Plain ws: proxy_pass http://127.0.0.1:4591/hybbx; -- cgit v1.3.1