Repository navigation
Serve WordPress from the alios share host in wordpress-dev images - #5
Closed
michaelaguiar wants to merge 1 commit into
Closed
michaelaguiar wants to merge 1 commit into
michaelaguiar wants to merge 1 commit into
Conversation
WordPress stores its URL in the database, so a site reached through an `alios share` tunnel redirects visitors back to https://<project>.test. The wordpress-dev variant now ships an auto_prepend_file that, only for requests the alios share vhost marks with `X-Alios-Share: 1`, filters home/siteurl to the forwarded public host (via pre-initialized hooks, so it also wins over WP_HOME/WP_SITEURL) and rewrites the stored host in text responses and Location headers. Normal .test requests and WP-CLI are untouched, nothing is written to the project, and the production wordpress variant is unchanged. The PHP is inlined as a Dockerfile heredoc so editing it triggers this variant's CI rebuild (change detection only watches the Dockerfiles). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
alios share(new in alios-cli) exposes a local project through a Cloudflare Tunnel. WordPress stores its URL in the database, so a shared WordPress site redirects every visitor back tohttps://<project>.test. Editing the project'swp-config.phpfrom the CLI was rejected: a leftover edit could get committed, and trusting the request host in production allows password-reset and cache poisoning. This PR puts the fix in the dev image instead.What
The
wordpress-devvariant (8.2–8.5) gets anauto_prepend_file,/usr/local/lib/php/alios-share.php. It only acts on requests carryingX-Alios-Share: 1. The alios share Caddy vhost sets that header itself, so tunnel visitors can't forge or strip it.For marked requests it:
option_home/option_siteurlto the forwarded public host, keeping any path (Bedrock/wp). The filter is registered through WordPress's pre-initialized$wp_filterhooks at priority 9999, after core's_config_wp_home, so it also overridesWP_HOME/WP_SITEURLdefines.Locationheaders, upgradinghttp://tohttps://.Unmarked requests (every normal
.testrequest, WP-CLI) return immediately. Nothing is written to the project, and the productionwordpressvariant is unchanged.The PHP is inlined as a Dockerfile heredoc because CI change detection only watches the Dockerfiles. A separate file wouldn't trigger a rebuild when edited.
Testing
I built
8.4-frankenphp-wordpress-devlocally and ran it against a real stock-WordPress site (code mounted read-only, committedwp-config.php):Host: <project>.test(no marker)https://<project>.test(unchanged)https://<project>.test/(existing behaviour)X-Alios-Share: 1/wp-admin/+ markerwp-login.phpwith public-hostredirect_to/wp-json/+ markerX-Forwarded-Host+ markerThe 8.2 variant also builds, and
php -lpasses on the prepend file. The 8.3 and 8.5 files are identical to 8.4 apart fromFROM.Caveats
auto_prepend_file(e.g. Wordfence's WAF) would override this one. That's unlikely in local dev.🤖 Generated with Claude Code