Thanks for your answers and help !
@Whitestrake
I’m sure I have the correct cookie when I’m connected :
@matt
Using this full Caddyfile (I tried creating two routes to see if it helps, and reversing the logic to avoid the not
directive) :
www.voiretmanger.fr,
nicolasfurno.fr,
www.nicolasfurno.fr,
nicolinux.fr,
www.nicolinux.fr {
redir https://voiretmanger.fr{uri}/
}
(static) {
@static {
file
path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.json
}
header @static Cache-Control max-age=5184000
}
voiretmanger.fr {
root * /var/www/voiretmanger.fr
encode zstd gzip
file_server
import static
log {
output file /var/log/caddy/voiretmanger.fr.access.log
}
# Redirect personnels
redir /a-propos/publicite /soutien
redir /archives/carte-des-restaurants /a-manger
header {
# enable HSTS
Strict-Transport-Security max-age=31536000;
# disable clients from sniffing the media type
X-Content-Type-Options nosniff
# keep referrer data off of HTTP connections
Referrer-Policy no-referrer-when-downgrade
}
@notcache {
header_regexp Cookie "(comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in)"
path_regexp "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(index)?.xml|[a-z0-9-]+-sitemap([0-9]+)?.xml)"
method POST
expression {query} != ''
}
route @notcache {
header cache wp
php_fastcgi unix//run/php/php7.4-fpm-caddy.sock
}
route {
header cache file
try_files /wp-content/cache/cache-enabler/{host}{uri}/index.html {path} {path}/index.php?{query}
php_fastcgi unix//run/php/php7.4-fpm-caddy.sock
}
request_header /wp-content Cache-Control "public, max-age=2592000, s-maxage=86400"
request_header /wp-includes Cache-Control "public, max-age=2592000, s-maxage=86400"
request_header /favicon.ico Cache-Control "public, max-age=2592000, s-maxage=86400"
}
files.voiretmanger.fr {
root * /var/www/files.voiretmanger.fr
encode zstd gzip
file_server browse
log {
output file /var/log/caddy/files.voiretmanger.fr.access.log
}
import static
}
memoire.nicolasfurno.fr {
root * /var/www/memoire.nicolasfurno.fr
encode zstd gzip
file_server
log {
output file /var/log/caddy/memoire.nicolasfurno.fr.access.log
}
import static
}
Here is the output of the caddy adapt
command :
{
"logging": {
"logs": {
"default": {
"exclude": [
"http.log.access.log2",
"http.log.access.log1",
"http.log.access.log0"
]
},
"log0": {
"writer": {
"filename": "/var/log/caddy/voiretmanger.fr.access.log",
"output": "file"
},
"include": [
"http.log.access.log0"
]
},
"log1": {
"writer": {
"filename": "/var/log/caddy/files.voiretmanger.fr.access.log",
"output": "file"
},
"include": [
"http.log.access.log1"
]
},
"log2": {
"writer": {
"filename": "/var/log/caddy/memoire.nicolasfurno.fr.access.log",
"output": "file"
},
"include": [
"http.log.access.log2"
]
}
}
},
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"memoire.nicolasfurno.fr"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "vars",
"root": "/var/www/memoire.nicolasfurno.fr"
},
{
"encodings": {
"gzip": {},
"zstd": {}
},
"handler": "encode"
},
{
"handler": "file_server",
"hide": [
"Caddyfile"
]
}
]
}
]
}
],
"terminal": true
},
{
"match": [
{
"host": [
"files.voiretmanger.fr"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "vars",
"root": "/var/www/files.voiretmanger.fr"
},
{
"encodings": {
"gzip": {},
"zstd": {}
},
"handler": "encode"
},
{
"browse": {},
"handler": "file_server",
"hide": [
"Caddyfile"
]
}
]
}
]
}
],
"terminal": true
},
{
"match": [
{
"host": [
"www.voiretmanger.fr",
"nicolasfurno.fr",
"www.nicolasfurno.fr",
"nicolinux.fr",
"www.nicolinux.fr"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"https://voiretmanger.fr{http.request.uri}/"
]
},
"status_code": 302
}
]
}
]
}
],
"terminal": true
},
{
"match": [
{
"host": [
"voiretmanger.fr"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "vars",
"root": "/var/www/voiretmanger.fr"
},
{
"handler": "headers",
"response": {
"set": {
"Referrer-Policy": [
"no-referrer-when-downgrade"
],
"Strict-Transport-Security": [
"max-age=31536000;"
],
"X-Content-Type-Options": [
"nosniff"
]
}
}
}
]
},
{
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"/a-manger"
]
},
"status_code": 302
}
],
"match": [
{
"path": [
"/archives/carte-des-restaurants"
]
}
]
},
{
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"/soutien"
]
},
"status_code": 302
}
],
"match": [
{
"path": [
"/a-propos/publicite"
]
}
]
},
{
"handle": [
{
"handler": "headers",
"request": {
"set": {
"Cache-Control": [
"public, max-age=2592000, s-maxage=86400"
]
}
}
}
],
"match": [
{
"path": [
"/wp-includes"
]
}
]
},
{
"handle": [
{
"handler": "headers",
"request": {
"set": {
"Cache-Control": [
"public, max-age=2592000, s-maxage=86400"
]
}
}
}
],
"match": [
{
"path": [
"/wp-content"
]
}
]
},
{
"handle": [
{
"handler": "headers",
"request": {
"set": {
"Cache-Control": [
"public, max-age=2592000, s-maxage=86400"
]
}
}
}
],
"match": [
{
"path": [
"/favicon.ic"
]
}
]
},
{
"handle": [
{
"encodings": {
"gzip": {},
"zstd": {}
},
"handler": "encode"
}
]
},
{
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "headers",
"response": {
"set": {
"Cache": [
"wp"
]
}
}
}
]
},
{
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"{http.request.uri.path}/"
]
},
"status_code": 308
}
],
"match": [
{
"file": {
"try_files": [
"{http.request.uri.path}/index.php"
]
},
"not": [
{
"path": [
"*/"
]
}
]
}
]
},
{
"handle": [
{
"handler": "rewrite",
"uri": "{http.matchers.file.relative}"
}
],
"match": [
{
"file": {
"split_path": [
".php"
],
"try_files": [
"{http.request.uri.path}",
"{http.request.uri.path}/index.php",
"index.php"
]
}
}
]
},
{
"handle": [
{
"handler": "reverse_proxy",
"transport": {
"protocol": "fastcgi",
"split_path": [
".php"
]
},
"upstreams": [
{
"dial": "unix//run/php/php7.4-fpm-caddy.sock"
}
]
}
],
"match": [
{
"path": [
"*.php"
]
}
]
}
]
}
],
"match": [
{
"expression": "{http.request.uri.query} != ''",
"header_regexp": {
"Cookie": {
"pattern": "(comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in)"
}
},
"method": [
"POST"
],
"path_regexp": {
"pattern": "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(index)?.xml|[a-z0-9-]+-sitemap([0-9]+)?.xml)"
}
}
]
},
{
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "headers",
"response": {
"set": {
"Cache": [
"file"
]
}
}
}
]
},
{
"group": "group0",
"handle": [
{
"handler": "rewrite",
"uri": "{http.matchers.file.relative}"
}
],
"match": [
{
"file": {
"try_files": [
"/wp-content/cache/cache-enabler/{http.request.host}{http.request.uri}/index.html",
"{http.request.uri.path}"
]
}
}
]
},
{
"group": "group0",
"handle": [
{
"handler": "rewrite",
"uri": "{http.matchers.file.relative}?{http.request.uri.query}"
}
],
"match": [
{
"file": {
"try_files": [
"{http.request.uri.path}/index.php"
]
}
}
]
},
{
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"{http.request.uri.path}/"
]
},
"status_code": 308
}
],
"match": [
{
"file": {
"try_files": [
"{http.request.uri.path}/index.php"
]
},
"not": [
{
"path": [
"*/"
]
}
]
}
]
},
{
"handle": [
{
"handler": "rewrite",
"uri": "{http.matchers.file.relative}"
}
],
"match": [
{
"file": {
"split_path": [
".php"
],
"try_files": [
"{http.request.uri.path}",
"{http.request.uri.path}/index.php",
"index.php"
]
}
}
]
},
{
"handle": [
{
"handler": "reverse_proxy",
"transport": {
"protocol": "fastcgi",
"split_path": [
".php"
]
},
"upstreams": [
{
"dial": "unix//run/php/php7.4-fpm-caddy.sock"
}
]
}
],
"match": [
{
"path": [
"*.php"
]
}
]
}
]
},
{
"handler": "file_server",
"hide": [
"Caddyfile"
]
}
]
}
]
}
],
"terminal": true
}
],
"logs": {
"logger_names": {
"files.voiretmanger.fr": "log1",
"memoire.nicolasfurno.fr": "log2",
"voiretmanger.fr": "log0"
},
"skip_hosts": [
"www.voiretmanger.fr",
"nicolasfurno.fr",
"www.nicolasfurno.fr",
"nicolinux.fr",
"www.nicolinux.fr"
]
}
}
}
},
"tls": {
"automation": {
"policies": [
{
"issuer": {
"email": "nicolinux@gmail.com",
"module": "acme"
}
}
]
}
}
}
}