1. The problem I’m having:
I’m trying to add Mercure to my existing Caddyfile (FrankenPHP).
This is my existing Caddyfile:
{
debug
log {
output file /home/tnio_gvr5s/caddy.log {
roll_size 10mb
roll_keep 5
roll_keep_for 720h
}
level INFO
}
}
easy-poly.fr {
root * /var/mon-vps/web/easy-poly.fr
handle / {
try_files {path} index.php
route {
php
}
}
handle /_php* {
route {
php
}
}
try_files {path}.html
handle {
file_server
}
try_files {path} {path}/ =404
handle_errors {
rewrite * /error.php?err_status_code={err.status_code}&err_status_text={err.status_text}&err_status_message={err.status_message}&err_status_trace={err.status_trace}&err_status_id={err.status_id}
php_server
}
log {
level INFO
format console
output file /home/tnio_gvr5s/wwwlogs/caddy-easy-poly.fr.log {
roll_size 10MiB
roll_local_time
roll_keep 10
roll_keep_for 336h
}
}
}
www.easy-poly.fr {
redir https://easy-poly.fr{uri} permanent
}
My goal was to make an effective Caddyfile:
- 1 route for php files
- another route for static files.
==> Am I right ?
And this is a tree view of my folders:
- php
- templates
- assets
- css
- js
- img
- fr (html)
- ge (html)
- en (html)
My existing Caddyfile works well :
- php, html files and assets are well displayed.
- error files are well catched.
But, when I try to add Mercure, it doesn’t work as I expected.
This is the new Caddyfile :
{
debug
log {
output file /home/tnio_gvr5s/caddy.log {
roll_size 10mb
roll_keep 5
roll_keep_for 720h
}
level INFO
}
}
easy-poly.fr {
mercure {
publisher_jwt D_C8nN@NYF-ifslz@!1CWdY+joY_b05+AADSm*iQ
subscriber_jwt hwHG3aYD9SkLypa9a+kt6dD-EojLW-xN0BrCjv*O
transport bolt {
path /home/tnio_ssh__7zys4mu4v/mercuretnio.db
bucket_name buck_tnio
size 1000
cleanup_frequency 0.5
}
cors_origins *
publish_origins *
subscriptions
publish
ui
}
root * /var/mon-vps/web/easy-poly.fr
handle / {
try_files {path} index.php
route {
php
}
}
handle /_php* {
route {
php
}
}
try_files {path}.html
handle {
file_server
}
try_files {path} {path}/ =404
handle_errors {
rewrite * /error.php?err_status_code={err.status_code}&err_status_text={err.status_text}&err_status_message={err.status_message}&err_status_trace={err.status_trace}&err_status_id={err.status_id}
php_server
}
log {
level INFO
format console
output file /home/tnio_gvr5s/wwwlogs/caddy-easy-poly.fr.log {
roll_size 10MiB
roll_local_time
roll_keep 10
roll_keep_for 336h
}
}
}
www.easy-poly.fr {
redir https://easy-poly.fr{uri} permanent
}
Results:
-
php, html files and assets are well displayed.
-
error files are well catched.
-
But, after this curl command to publish :
curl -X POST https://easy-poly.fr/.well-known/mercure \\
-d 'topic=https://easy-poly.fr/books/1' \\
-d 'data={"foo": "updated value"}' \\
-H 'Authorization: Bearer epc2I6Ip7cW1DLmKi3x-iEdccgXf7-LVNzmKi3x-iEdccgXf7-LVNzmKi3x-iEdccgXf7-LVNzmKi3x-iEdccgXf7-LVNz2FkKhVbGUM'
==> I get redirected to error.php instead of getting uuid.
2. Error messages and/or full log output:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ERROR 404</title>
</head>
<body>
<h1>ERROR !!!</h1>
<br>err_status_code 404 !!!
<br>err_status_text Not Found !!!
<br>err_status_message <nil> !!!
<br>err_status_trace <nil> !!!
<br>err_status_id <nil> !!!
<hr>page : error.php
<br>The current file name is: mercure
</body>
3. Caddy version:
frankenphp version:
v2.10.2
4. How I installed and ran Caddy:
Install PHP by compiling:
Compile the Go App using xcaddy:
a. System environment:
DEBIAN 13 (no Docker)