What happened?
Hey All!
Im trying to see if its possible to get Xenforo working with FrankenPHP.
This is my Caddyfile
{
{$CADDY_GLOBAL_OPTIONS}
frankenphp {
worker ./worker.php
}
order mercure after encode
order vulcain after reverse_proxy
order php_server before file_server
order php before file_server
}
forum.mydomain.net {
# Set the root to the /xenforo directory
root * /app
# Enable compression encoders
encode zstd br gzip
# Include additional server directives (if any)
{$CADDY_SERVER_EXTRA_DIRECTIVES}
php_server {
index index.php
}
# Additional configurations for Xenforo can be placed here
tls {
dns cloudflare {env.CF_API_TOKEN}
}
}
This is my worker.php that I have tried to make to work well with Xenforo
<?php
// /app/worker.php
// Prevent worker script termination when a client connection is interrupted
ignore_user_abort(true);
// Boot Xenforo
// Adjust the path to reflect the location of Xenforo's initialization file
require __DIR__ . '/src/XF.php';
// Start the application
\XF::start();
// Handler outside the loop for better performance (doing less work)
$handler = static function () {
// Called when a request is received
$app = \XF::setupApp('XF\Pub\App');
// Process the request and return the response
$response = $app->run();
$response->send();
};
// Handle requests with a limit on the number of requests or other termination conditions
for ($nbRequests = 0, $running = true; isset($_SERVER['MAX_REQUESTS']) && ($nbRequests < (int)$_SERVER['MAX_REQUESTS']) && $running; ++$nbRequests) {
$running = \frankenphp_handle_request($handler);
// Do something after sending the HTTP response
$app->terminate();
// Call the garbage collector
gc_collect_cycles();
}
// Cleanup (if applicable)
\XF::shutdown();
However when I do docker compose up you can see from the logs what it spams in my console.
I gather its an issue to do with the worker.php but I have no clue where to start to figure out what the issue may be?
Any guidance would be greatly appreciated! :)
docker-composer.yml if its of any use
services:
frankenphp:
image: xenforo-forum
restart: always
ports:
- "8080:80" # HTTP
- "9445:443" # HTTPS
- "9445:443/udp" # HTTP/3
volumes:
- /home/josh/xenforo:/app
- /home/josh/xenforo-environment/Caddyfile:/caddy-config/Caddyfile
- caddy_data:/data
- caddy_config:/config
environment:
- MAX_REQUESTS=1000
command: ["--config", "/caddy-config/Caddyfile"]
volumes:
caddy_data:
caddy_config:
Build Type
Docker (Debian Bookworm)
Worker Mode
Yes
Operating System
GNU/Linux
CPU Architecture
x86_64
PHP configuration
Relevant log output
frankenphp-1 | {"level":"error","ts":1715298046.7656398,"msg":"unexpected termination, restarting","worker":"/app/worker.php","exit_status":255}
frankenphp-1 | {"level":"error","ts":1715298046.7660913,"msg":"unexpected termination, restarting","worker":"/app/worker.php","exit_status":255}
What happened?
Hey All!
Im trying to see if its possible to get Xenforo working with FrankenPHP.
This is my Caddyfile
{ {$CADDY_GLOBAL_OPTIONS} frankenphp { worker ./worker.php } order mercure after encode order vulcain after reverse_proxy order php_server before file_server order php before file_server } forum.mydomain.net { # Set the root to the /xenforo directory root * /app # Enable compression encoders encode zstd br gzip # Include additional server directives (if any) {$CADDY_SERVER_EXTRA_DIRECTIVES} php_server { index index.php } # Additional configurations for Xenforo can be placed here tls { dns cloudflare {env.CF_API_TOKEN} } }This is my worker.php that I have tried to make to work well with Xenforo
However when I do
docker compose upyou can see from the logs what it spams in my console.I gather its an issue to do with the worker.php but I have no clue where to start to figure out what the issue may be?
Any guidance would be greatly appreciated! :)
docker-composer.yml if its of any use
Build Type
Docker (Debian Bookworm)
Worker Mode
Yes
Operating System
GNU/Linux
CPU Architecture
x86_64
PHP configuration
Relevant log output