I think I figured it out thanks to your suggestion before. The page is now rendering OK for basic usage.
Still don’t understand how the rewrite rules work, but I am getting there I think 
wikidev.tnonline.net:443 {
tls /etc/letsencrypt/live/wikidev.tnonline.net/fullchain.pem /etc/letsencrypt/live/wikidev.tnonline.net/privkey.pem {
}
bind 2001:470:28:704::100
@title {
not file {path} {path}/w/
not path /mediawiki/rest.php
path_regexp title ^/(.*)$
}
rewrite @title /mediawiki/index.php?title={re.title.1}&{query}
root * /var/www/domains/wikidev.tnonline.net/htdocs
php_fastcgi unix//var/run/php-fpm/fpm-wiki.socket
file_server
}
Mediawiki Localsettings.php
## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/mediawiki";
$wgScriptExtension = ".php";
$wgArticlePath = "/w/$1";
$wgUsePathInfo = true;
## The protocol and server name to use in fully-qualified URLs
$wgServer = "https://wikidev.tnonline.net";
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;
What is not working is the Visual editor which is throwing an error:
"code": "apierror-visualeditor-docserver-http",
"info": "Error contacting the Parsoid/RESTBase server (HTTP 400)",
"docref": "See https://wikidev.tnonline.net/mediawiki/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes."
}
}
The caddy debug log is:
2021/09/16 06:35:15.993 INFO using adjacent Caddyfile
2021/09/16 06:35:15.995 WARN input is not formatted with 'caddy fmt' {"adapter": "caddyfile", "file": "Caddyfile", "line": 37}
2021/09/16 06:35:15.996 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2021/09/16 06:35:15.997 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc0002a6000"}
2021/09/16 06:35:15.998 INFO http enabling experimental HTTP/3 listener {"addr": ":60000"}
2021/09/16 06:35:15.998 DEBUG http starting server loop {"address": "[::]:60000", "http3": true, "tls": true}
2021/09/16 06:35:15.998 INFO http enabling experimental HTTP/3 listener {"addr": "[2001:470:28:704::100]:443"}
2021/09/16 06:35:15.998 DEBUG http starting server loop {"address": "[2001:470:28:704::100]:443", "http3": true, "tls": true}
2021/09/16 06:35:15.998 DEBUG http starting server loop {"address": "[2001:470:28:704::100]:80", "http3": false, "tls": false}
2021/09/16 06:35:15.998 INFO autosaved config (load with --resume flag) {"file": "/root/.config/caddy/autosave.json"}
2021/09/16 06:35:15.998 INFO serving initial configuration
2021/09/16 06:35:15.998 INFO tls cleaning storage unit {"description": "FileStorage:/root/.local/share/caddy"}
2021/09/16 06:35:15.999 INFO tls finished cleaning storage units
2021/09/16 06:35:19.991 DEBUG http.reverse_proxy.transport.fastcgi roundtrip {"request": {"remote_addr": "[2001:470:df1b::333]:52318", "proto": "HTTP/2.0", "method": "POST", "host": "wikidev.tnonline.net", "uri": "/mediawiki/api.php", "headers": {"User-Agent": ["Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0"], "Accept": ["application/json, text/javascript, */*; q=0.01"], "Content-Length": ["81"], "Sec-Fetch-Dest": ["empty"], "Sec-Fetch-Mode": ["cors"], "Sec-Fetch-Site": ["same-origin"], "Referer": ["https://wikidev.tnonline.net/mediawiki/index.php?title=Main_Page&action=edit"], "Cookie": ["VEE=visualeditor; my_wikimwuser-sessionId=63c596394bc1200d40ee"], "Te": ["trailers"], "X-Forwarded-For": ["2001:470:df1b::333"], "Accept-Encoding": ["gzip, deflate, br"], "Content-Type": ["application/x-www-form-urlencoded; charset=UTF-8"], "Origin": ["https://wikidev.tnonline.net"], "Cache-Control": ["no-cache"], "X-Forwarded-Proto": ["https"], "Accept-Language": ["en-US,en;q=0.5"], "X-Requested-With": ["XMLHttpRequest"], "Pragma": ["no-cache"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "proto_mutual": true, "server_name": "wikidev.tnonline.net"}}, "dial": "/var/run/php-fpm/fpm-wiki.socket", "env": {"AUTH_TYPE":"","CONTENT_LENGTH":"81","CONTENT_TYPE":"application/x-www-form-urlencoded; charset=UTF-8","DOCUMENT_ROOT":"/var/www/domains/wikidev.tnonline.net/htdocs","DOCUMENT_URI":"/mediawiki/api.php","GATEWAY_INTERFACE":"CGI/1.1","HTTPS":"on","HTTP_ACCEPT":"application/json, text/javascript, */*; q=0.01","HTTP_ACCEPT_ENCODING":"gzip, deflate, br","HTTP_ACCEPT_LANGUAGE":"en-US,en;q=0.5","HTTP_CACHE_CONTROL":"no-cache","HTTP_CONTENT_LENGTH":"81","HTTP_CONTENT_TYPE":"application/x-www-form-urlencoded; charset=UTF-8","HTTP_COOKIE":"VEE=visualeditor; my_wikimwuser-sessionId=63c596394bc1200d40ee","HTTP_HOST":"wikidev.tnonline.net","HTTP_ORIGIN":"https://wikidev.tnonline.net","HTTP_PRAGMA":"no-cache","HTTP_REFERER":"https://wikidev.tnonline.net/mediawiki/index.php?title=Main_Page&action=edit","HTTP_SEC_FETCH_DEST":"empty","HTTP_SEC_FETCH_MODE":"cors","HTTP_SEC_FETCH_SITE":"same-origin","HTTP_TE":"trailers","HTTP_USER_AGENT":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0","HTTP_X_FORWARDED_FOR":"2001:470:df1b::333","HTTP_X_FORWARDED_PROTO":"https","HTTP_X_REQUESTED_WITH":"XMLHttpRequest","PATH_INFO":"","QUERY_STRING":"","REMOTE_ADDR":"2001:470:df1b::333","REMOTE_HOST":"2001:470:df1b::333","REMOTE_IDENT":"","REMOTE_PORT":"52318","REMOTE_USER":"","REQUEST_METHOD":"POST","REQUEST_SCHEME":"https","REQUEST_URI":"/mediawiki/api.php","SCRIPT_FILENAME":"/var/www/domains/wikidev.tnonline.net/htdocs/mediawiki/api.php","SCRIPT_NAME":"/mediawiki/api.php","SERVER_NAME":"wikidev.tnonline.net","SERVER_PROTOCOL":"HTTP/2.0","SERVER_SOFTWARE":"Caddy/(devel)","SSL_CIPHER":"TLS_AES_128_GCM_SHA256","SSL_PROTOCOL":"TLSv1.3"}}
2021/09/16 06:35:20.302 DEBUG http.handlers.reverse_proxy upstream roundtrip {"upstream": "unix//var/run/php-fpm/fpm-wiki.socket", "request": {"remote_addr": "[2001:470:df1b::333]:52318", "proto": "HTTP/2.0", "method": "POST", "host": "wikidev.tnonline.net", "uri": "/mediawiki/api.php", "headers": {"Accept-Language": ["en-US,en;q=0.5"], "X-Requested-With": ["XMLHttpRequest"], "Pragma": ["no-cache"], "User-Agent": ["Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0"], "Accept": ["application/json, text/javascript, */*; q=0.01"], "Content-Length": ["81"], "Sec-Fetch-Dest": ["empty"], "Sec-Fetch-Mode": ["cors"], "Sec-Fetch-Site": ["same-origin"], "Referer": ["https://wikidev.tnonline.net/mediawiki/index.php?title=Main_Page&action=edit"], "Cookie": ["VEE=visualeditor; my_wikimwuser-sessionId=63c596394bc1200d40ee"], "Te": ["trailers"], "X-Forwarded-For": ["2001:470:df1b::333"], "Accept-Encoding": ["gzip, deflate, br"], "Content-Type": ["application/x-www-form-urlencoded; charset=UTF-8"], "Origin": ["https://wikidev.tnonline.net"], "Cache-Control": ["no-cache"], "X-Forwarded-Proto": ["https"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "proto_mutual": true, "server_name": "wikidev.tnonline.net"}}, "headers": {"X-Frame-Options": ["DENY"], "Content-Disposition": ["inline; filename=api-result.json"], "Cache-Control": ["private, must-revalidate, max-age=0"], "X-Request-Id": ["272d9397b8488766f1031583"], "X-Content-Type-Options": ["nosniff"], "Content-Type": ["application/json; charset=utf-8"]}, "status": 200}
2021/09/16 06:35:20.318 DEBUG http.reverse_proxy.transport.fastcgi roundtrip {"request": {"remote_addr": "[2001:470:df1b::333]:52318", "proto": "HTTP/2.0", "method": "GET", "host": "wikidev.tnonline.net", "uri": "/mediawiki/api.php?action=visualeditor&format=json&paction=parse&page=Main_Page&uselang=en-gb&formatversion=2", "headers": {"Sec-Fetch-Site": ["same-origin"], "Pragma": ["no-cache"], "User-Agent": ["Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0"], "Accept-Encoding": ["gzip, deflate, br"], "Cookie": ["VEE=visualeditor; my_wikimwuser-sessionId=63c596394bc1200d40ee"], "Accept-Language": ["en-US,en;q=0.5"], "Referer": ["https://wikidev.tnonline.net/mediawiki/index.php?title=Main_Page&action=edit"], "Te": ["trailers"], "X-Requested-With": ["XMLHttpRequest"], "Cache-Control": ["no-cache"], "X-Forwarded-For": ["2001:470:df1b::333"], "X-Forwarded-Proto": ["https"], "Accept": ["application/json, text/javascript, */*; q=0.01"], "Sec-Fetch-Dest": ["empty"], "Sec-Fetch-Mode": ["cors"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "proto_mutual": true, "server_name": "wikidev.tnonline.net"}}, "dial": "/var/run/php-fpm/fpm-wiki.socket", "env": {"AUTH_TYPE":"","CONTENT_LENGTH":"","CONTENT_TYPE":"","DOCUMENT_ROOT":"/var/www/domains/wikidev.tnonline.net/htdocs","DOCUMENT_URI":"/mediawiki/api.php","GATEWAY_INTERFACE":"CGI/1.1","HTTPS":"on","HTTP_ACCEPT":"application/json, text/javascript, */*; q=0.01","HTTP_ACCEPT_ENCODING":"gzip, deflate, br","HTTP_ACCEPT_LANGUAGE":"en-US,en;q=0.5","HTTP_CACHE_CONTROL":"no-cache","HTTP_COOKIE":"VEE=visualeditor; my_wikimwuser-sessionId=63c596394bc1200d40ee","HTTP_HOST":"wikidev.tnonline.net","HTTP_PRAGMA":"no-cache","HTTP_REFERER":"https://wikidev.tnonline.net/mediawiki/index.php?title=Main_Page&action=edit","HTTP_SEC_FETCH_DEST":"empty","HTTP_SEC_FETCH_MODE":"cors","HTTP_SEC_FETCH_SITE":"same-origin","HTTP_TE":"trailers","HTTP_USER_AGENT":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0","HTTP_X_FORWARDED_FOR":"2001:470:df1b::333","HTTP_X_FORWARDED_PROTO":"https","HTTP_X_REQUESTED_WITH":"XMLHttpRequest","PATH_INFO":"","QUERY_STRING":"action=visualeditor&format=json&paction=parse&page=Main_Page&uselang=en-gb&formatversion=2","REMOTE_ADDR":"2001:470:df1b::333","REMOTE_HOST":"2001:470:df1b::333","REMOTE_IDENT":"","REMOTE_PORT":"52318","REMOTE_USER":"","REQUEST_METHOD":"GET","REQUEST_SCHEME":"https","REQUEST_URI":"/mediawiki/api.php?action=visualeditor&format=json&paction=parse&page=Main_Page&uselang=en-gb&formatversion=2","SCRIPT_FILENAME":"/var/www/domains/wikidev.tnonline.net/htdocs/mediawiki/api.php","SCRIPT_NAME":"/mediawiki/api.php","SERVER_NAME":"wikidev.tnonline.net","SERVER_PROTOCOL":"HTTP/2.0","SERVER_SOFTWARE":"Caddy/(devel)","SSL_CIPHER":"TLS_AES_128_GCM_SHA256","SSL_PROTOCOL":"TLSv1.3"}}
2021/09/16 06:35:20.399 DEBUG http.handlers.rewrite rewrote request {"request": {"remote_addr": "[2001:470:28:704::100]:55288", "proto": "HTTP/2.0", "method": "GET", "host": "wikidev.tnonline.net", "uri": "/mediawiki/rest.php/wikidev.tnonline.net/v3/page/html/Main_Page/1056?redirect=false&stash=true", "headers": {"Accept": ["text/html; charset=utf-8; profile=\"https://www.mediawiki.org/wiki/Specs/HTML/2.0.0\""], "Accept-Language": ["en-gb"], "User-Agent": ["VisualEditor-MediaWiki/1.36.0"], "Api-User-Agent": ["VisualEditor-MediaWiki/1.36.0"], "Promise-Non-Write-Api-Action": ["true"], "Content-Length": ["0"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "proto_mutual": true, "server_name": "wikidev.tnonline.net"}}, "method": "GET", "uri": "/mediawiki/index.php?title=mediawiki%2Frest.php%2Fwikidev.tnonline.net%2Fv3%2Fpage%2Fhtml%2FMain_Page%2F1056&redirect=false&stash=true"}
2021/09/16 06:35:20.399 DEBUG http.reverse_proxy.transport.fastcgi roundtrip {"request": {"remote_addr": "[2001:470:28:704::100]:55288", "proto": "HTTP/2.0", "method": "GET", "host": "wikidev.tnonline.net", "uri": "/mediawiki/index.php?title=mediawiki%2Frest.php%2Fwikidev.tnonline.net%2Fv3%2Fpage%2Fhtml%2FMain_Page%2F1056&redirect=false&stash=true", "headers": {"Content-Length": ["0"], "X-Forwarded-For": ["2001:470:28:704::100"], "X-Forwarded-Proto": ["https"], "Accept": ["text/html; charset=utf-8; profile=\"https://www.mediawiki.org/wiki/Specs/HTML/2.0.0\""], "Accept-Language": ["en-gb"], "User-Agent": ["VisualEditor-MediaWiki/1.36.0"], "Api-User-Agent": ["VisualEditor-MediaWiki/1.36.0"], "Promise-Non-Write-Api-Action": ["true"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "proto_mutual": true, "server_name": "wikidev.tnonline.net"}}, "dial": "/var/run/php-fpm/fpm-wiki.socket", "env": {"AUTH_TYPE":"","CONTENT_LENGTH":"0","CONTENT_TYPE":"","DOCUMENT_ROOT":"/var/www/domains/wikidev.tnonline.net/htdocs","DOCUMENT_URI":"/mediawiki/index.php","GATEWAY_INTERFACE":"CGI/1.1","HTTPS":"on","HTTP_ACCEPT":"text/html; charset=utf-8; profile=\"https://www.mediawiki.org/wiki/Specs/HTML/2.0.0\"","HTTP_ACCEPT_LANGUAGE":"en-gb","HTTP_API_USER_AGENT":"VisualEditor-MediaWiki/1.36.0","HTTP_CONTENT_LENGTH":"0","HTTP_HOST":"wikidev.tnonline.net","HTTP_PROMISE_NON_WRITE_API_ACTION":"true","HTTP_USER_AGENT":"VisualEditor-MediaWiki/1.36.0","HTTP_X_FORWARDED_FOR":"2001:470:28:704::100","HTTP_X_FORWARDED_PROTO":"https","PATH_INFO":"","QUERY_STRING":"title=mediawiki%2Frest.php%2Fwikidev.tnonline.net%2Fv3%2Fpage%2Fhtml%2FMain_Page%2F1056&redirect=false&stash=true","REMOTE_ADDR":"2001:470:28:704::100","REMOTE_HOST":"2001:470:28:704::100","REMOTE_IDENT":"","REMOTE_PORT":"55288","REMOTE_USER":"","REQUEST_METHOD":"GET","REQUEST_SCHEME":"https","REQUEST_URI":"/mediawiki/rest.php/wikidev.tnonline.net/v3/page/html/Main_Page/1056?redirect=false&stash=true","SCRIPT_FILENAME":"/var/www/domains/wikidev.tnonline.net/htdocs/mediawiki/index.php","SCRIPT_NAME":"/mediawiki/index.php","SERVER_NAME":"wikidev.tnonline.net","SERVER_PROTOCOL":"HTTP/2.0","SERVER_SOFTWARE":"Caddy/(devel)","SSL_CIPHER":"TLS_AES_128_GCM_SHA256","SSL_PROTOCOL":"TLSv1.3"}}
2021/09/16 06:35:20.409 DEBUG http.handlers.reverse_proxy upstream roundtrip {"upstream": "unix//var/run/php-fpm/fpm-wiki.socket", "request": {"remote_addr": "[2001:470:28:704::100]:55288", "proto": "HTTP/2.0", "method": "GET", "host": "wikidev.tnonline.net", "uri": "/mediawiki/index.php?title=mediawiki%2Frest.php%2Fwikidev.tnonline.net%2Fv3%2Fpage%2Fhtml%2FMain_Page%2F1056&redirect=false&stash=true", "headers": {"Content-Length": ["0"], "X-Forwarded-For": ["2001:470:28:704::100"], "X-Forwarded-Proto": ["https"], "Accept": ["text/html; charset=utf-8; profile=\"https://www.mediawiki.org/wiki/Specs/HTML/2.0.0\""], "Accept-Language": ["en-gb"], "User-Agent": ["VisualEditor-MediaWiki/1.36.0"], "Api-User-Agent": ["VisualEditor-MediaWiki/1.36.0"], "Promise-Non-Write-Api-Action": ["true"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "proto_mutual": true, "server_name": "wikidev.tnonline.net"}}, "headers": {"Status": ["400 Bad Request"], "X-Content-Type-Options": ["nosniff"], "Cache-Control": ["no-cache"], "Content-Type": ["text/html; charset=utf-8"], "Content-Length": ["194"], "X-Request-Id": ["7d4c2e790d81eb7c86b441e5"]}, "status": 400}
2021/09/16 06:35:20.416 DEBUG http.handlers.reverse_proxy upstream roundtrip {"upstream": "unix//var/run/php-fpm/fpm-wiki.socket", "request": {"remote_addr": "[2001:470:df1b::333]:52318", "proto": "HTTP/2.0", "method": "GET", "host": "wikidev.tnonline.net", "uri": "/mediawiki/api.php?action=visualeditor&format=json&paction=parse&page=Main_Page&uselang=en-gb&formatversion=2", "headers": {"Referer": ["https://wikidev.tnonline.net/mediawiki/index.php?title=Main_Page&action=edit"], "Te": ["trailers"], "Accept-Language": ["en-US,en;q=0.5"], "Cache-Control": ["no-cache"], "X-Forwarded-For": ["2001:470:df1b::333"], "X-Requested-With": ["XMLHttpRequest"], "Sec-Fetch-Dest": ["empty"], "Sec-Fetch-Mode": ["cors"], "X-Forwarded-Proto": ["https"], "Accept": ["application/json, text/javascript, */*; q=0.01"], "Accept-Encoding": ["gzip, deflate, br"], "Cookie": ["VEE=visualeditor; my_wikimwuser-sessionId=63c596394bc1200d40ee"], "Sec-Fetch-Site": ["same-origin"], "Pragma": ["no-cache"], "User-Agent": ["Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "proto_mutual": true, "server_name": "wikidev.tnonline.net"}}, "headers": {"Content-Disposition": ["inline; filename=api-result.json"], "Cache-Control": ["private, must-revalidate, max-age=0"], "X-Request-Id": ["9f3eb4e7c62d1d13fbc89a34"], "X-Content-Type-Options": ["nosniff"], "Mediawiki-Api-Error": ["apierror-visualeditor-docserver-http"], "Content-Type": ["application/json; charset=utf-8"], "X-Frame-Options": ["DENY"]}, "status": 200}
I cannot really see anything wrong in the actual URL’s requested. They look the same on the live server as on this. But for some reason the Visual editor is not working. Perhaps it is using some socket connection not working through the reverse_proxy bit?
Caddy: https://wikidev.tnonline.net/w/Main_Page?veaction=edit
Apache: https://wiki.tnonline.net/w/Main_Page?veaction=edit
It may be a MediaWiki configuration error, but hard to tell. The codebase is identical between the Apache and Caddy setup. I’ll check with the guys over at #mediawiki to see if they have any ideas here.