Drupal 10, the latest version of the open-source digital experience platform with even more features, is here.To reproduce:
- Navigate to a Site node.
- Run a Reset password task.
- After the task completes, click on the Login to site link.
- This won't work as the URL isn't the subdirectory version, but move the domain prefix after the slash, and try again.
- The login process will redirect to the subdomain URL instead of the subdirectory URL, and the request will fail.
Further illustration:
colan@leopard[Fri 11 14:49]% curl -I https://example.com/site1/user/reset/1/1547236225/0s08V0zksIkEcWxFDFnEvW0uN0VQAU_klgJq0yXX-xY/login
[...]
location: https://site1.example.com/site1/user/1/edit?pass-reset-token=Dkq3-rINUzJnm3ZtZcVjdIXXeCjEur6LfyVPqX5pRIFiHjj2vytljLCZhTpTWHN2IO7RTh6onw
[...]
As can be seen above, it's adding a subdomain to the URL when it shouldn't.
This could be a problem with Aegir's subdirectory mode for Drupal 8 sites, which don't recognize $base_url, or a Drupal core issue such as #2753591: Fix mismatch of $base_url with Symfony request object.
Further digging is required.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | provision-fix_subdir_login_urls-3025905-15.patch | 1.4 KB | llamech |











Comments
Comment #2
memtkmcc CreditAttribution: memtkmcc at Omega8.cc commentedI have checked our support queue and as it turned out, it never actually worked for us, so we have always used a simple albeit rather silly workaround: adding standard subdomain alias like login.domain.foo so admins and users could log in via login.domain.foo/user instead of domain.foo/bar/user
Comment #3
colanAfter some more research, I think #2 is the second part of a two-part problem that I haven't figured out yet.
The first part of the problem is that #3014381: Logins impossible on subdirectory sites needs to be implemented in D8. Setting the cookie path is easy; that's done the same way as in D7. However, setting the cookie domain needs to be done in the site's
services.ymlfile like so:While this file is being included, I don't believe we ever create it. What's a good way to append the above to that file (generating it if necessary) during a Verify task?
Comment #7
colanI believe I did all that's necessary in Provision (in this branch), but now we need
hosting_subdirsto write thesubdirs.services.ymlfile we call here. That needs to be done in Hosting.I tried, but couldn't get this to work, trying various alterations:
http://docs.aegirproject.org/en/3.x/extend/altering-behaviours/#develope... seems to be incorrect. We need to fix that as well, and add a section for how to do stuff in a Verify task.
Comment #8
ergonlogicComment #9
ergonlogicIt looks like the
services.ymlis being loaded via the$settings['container_yamls']variable insettings.php. This appears to be an array, and so we should be able to provide both a generated file and allow site owner overrides with something like:Comment #10
ergonlogicThis patch generates an
aegir.services.ymlfile, populates it with a cookie domain, and includes it insettings.php.This appears to allow proper link URLs, pointing to the subdir (
example.com/site1) in all internal links when logged in. However, when visiting the site anonymously, links drop the subdir, and thus fail. I suspect there's link construction is using some other replacement to$base_url(not cookie domain) for anonymous traffic.Also, with #3034235: Use alias redirection target when creating goto/login link, we generate proper login/go-to links, with subdirs when enabled. However, the redirect appears to be duplicating the subdir segment in the link (e.g.,
http://example.com/site1/site1/user/...). So that's another challenge.FYI, I'm working on this in the
dev/fix-login-linksbranches of Hosting and Provision.Comment #11
ergonlogicIt looks like we were constructing a
$base_urlvariable to add our subdir segment, but not declaring itglobal.I'm not certain this is the best solution, considering Removed base_url option from settings.php and related initiatives to remove
$base_url. But it appears to work.Comment #12
ergonlogicThat last fix appears to have resolved this issue.Sorry, testing fail. I'd built the site on a D7 platform.
Comment #13
ergonlogicWe have confirmed that D7 subdir sites work properly on both Apache and Nginx. In addition, D8 sites work on Apache.
D8 sites on Nginx exhibit the following behaviour:
Drupal 8 appears to contruct its base URL by examining request headers, according to Drupal 8's API docs
Examining the headers from a (working) site on Apache, and comparing to a (non-functional) site on Nginx looks promising. Here are some notable differences:
Comment #14
ergonlogicSetting the following headers appears to fix the problematic behaviour completely:
It's possible that a couple are redundant, but our current plan is to set all these in Nginx vhosts.
Comment #15
llamechComment #16
llamechThe attached patch adds the headers mentioned in #14 to the location block for index.php within the subdir vhosts for nginx.
In testing, this solves the login links problem and the other behaviours mentioned in #13.
However, we've noticed there are 4 other location blocks in the vhosts template where similar treatment is probably needed (e.g. for update.php, cron.php etc.). Our attempts to remediate these failed. This can be followed up in a separate issue.
It's worth mentioning that cron still works within the site.
Comment #17
llamechShould be fixed; needs testing.
Comment #18
memtkmcc CreditAttribution: memtkmcc at Omega8.cc commentedI will have to check and review this closely for Nginx part, but I believe there was a reason why we have added
RAW_HOSTand forcedHTTP_HOSTto match the site name$this->uriinstead, not a current Nginx local$hostIt was perhaps because we have then used in the global.inc some extra logic to handle sessions and other stuff to make it work:
Comment #19
memtkmcc CreditAttribution: memtkmcc at Omega8.cc commentedToo bad we never shared this BOA specific stuff with upstream, so it was never noticed nor followed up, while worked (mostly) for us.
Comment #20
llamechFixes for this, along with other subdirectory site fixes, are all in #3036890: Simplify subdir site installation. For simplicity, let's validate there.
Comment #22
ergonlogicWe're merging fixes from #3036890: Simplify subdir site installation, which resolves this issue too.
Comment #24
colanSee #3066538: Cookie subdomains missing first part of subdomain for non-subdirectory sites for a follow-up, based on a bug introduced here.
Comment #25
colan