Skip to content

Bugfix/vhost issues roundup#16

Open
kdallas wants to merge 2 commits into
devilbox-community:mainlinefrom
kdallas:bugfix/vhost-issues-roundup
Open

Bugfix/vhost issues roundup#16
kdallas wants to merge 2 commits into
devilbox-community:mainlinefrom
kdallas:bugfix/vhost-issues-roundup

Conversation

@kdallas

@kdallas kdallas commented Jun 27, 2026

Copy link
Copy Markdown

BUGFIX_VHOSTS

Goal

General QoL clean ups

DESCRIPTION

Mainly I wanted to harden up the Curl requests so they can't hang PHP-FPM. I also would always see WARN status on my correctly configured vHosts so now we will see green OK responses.

Here's a breakdown of findings that this PR resolves:

┌──────────┬─────────────────────────────────────────────────────────────────────┬───────────────────────┐
  │ Severity │                                Issue                                │       Location        │
  ├──────────┼─────────────────────────────────────────────────────────────────────┼───────────────────────┤
  │ Medium   │ $_SERVER['HTTP_HOST'] used unsanitized in server-side HTTP requests │ vhosts.php:56-57      │
  ├──────────┼─────────────────────────────────────────────────────────────────────┼───────────────────────┤
  │ Medium   │ cURL has no timeout — can hang PHP-FPM workers                      │ Httpd.php:138-142     │
  ├──────────┼─────────────────────────────────────────────────────────────────────┼───────────────────────┤
  │ Low      │ IPv6 address parsing hack in backend.cfg                            │ Httpd.php:228-231     │
  ├──────────┼─────────────────────────────────────────────────────────────────────┼───────────────────────┤
  │ Low      │ fopen return value not checked                                      │ Httpd.php:214         │
  ├──────────┼─────────────────────────────────────────────────────────────────────┼───────────────────────┤
  │ Low      │ Unscoped JS variable i                                              │ vhosts.php:281        │
  ├──────────┼─────────────────────────────────────────────────────────────────────┼───────────────────────┤
  │ Low      │ Race between XHR timeout and success handler                        │ vhosts.php:243-276    │
  ├──────────┼─────────────────────────────────────────────────────────────────────┼───────────────────────┤
  │ Low      │ POST used for read-only status check                                │ vhosts.php:262        │
  ├──────────┼─────────────────────────────────────────────────────────────────────┼───────────────────────┤
  │ Info     │ Hardcoded IP in daemons table                                       │ vhosts.php:173        │
  ├──────────┼─────────────────────────────────────────────────────────────────────┼───────────────────────┤
  │ Info     │ Inconsistent AJAX response format (HTML vs JSON)                    │ _ajax_callback.php:30 │
  └──────────┴─────────────────────────────────────────────────────────────────────┴───────────────────────┘

Larry Browning and others added 2 commits June 27, 2026 18:46
Security:
- Replace $_SERVER['HTTP_HOST'] with Docker internal hostname to prevent SSRF
- Add cURL connect/read timeouts (3s/5s) to prevent hung PHP-FPM workers

Robustness:
- Add fopen() error handling in getVhostBackend() with logged warning
- Clean up IPv6 address parsing using array_pop/implode/array_slice
- Replace hardcoded PHP container IP with dynamic gethostname()/SERVER_ADDR
- Fix XHR timeout race: use native xhr.ontimeout instead of manual setTimeout
- Make vhost AJAX endpoint return consistent JSON with status/message fields

Cleanup:
- Fix unscoped JS variable (i) in for-loop
- Change read-only status check from POST to GET
- Fix operator precedence in XHR status check (readyState vs status)
- Remove dead/commented-out code in checkDns()
- Add backup files and local shell scripts to .gitignore

Co-Authored-By: Claude <noreply@anthropic.com>
canConnect() was always connecting on port 80, but the PHP container's
socat forwarding listens on HOST_PORT_HTTPD (e.g. 8001), not 80.
This made every vhost show WARN because the internal cURL check
targeted 127.0.0.1:80 where nothing was listening.

Use getPort() to append the configured port to the cURL URL.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant