Pages redirect duplicates domain in auth parameter when namespace_in_path is enabled

Summary

A large self-managed GitLab Ultimate customer reported in ZD#673388 that pages endpoints are redirecting to incorrect URLs with duplicated domain names in the auth parameter. This behavior is inconsistent across pages and started appearing in version 18.4.3. They can reproduce with 18.5.3 as well.

Configuration

external_url 'https://${gitlab_fqdn}'
pages_external_url 'https://${pages_fqdn}'

gitlab_rails['pages_object_store_remote_directory'] = '${gitlab_pages_bucket}'

gitlab_pages['enable'] = true
gitlab_pages['gitlab_server'] = 'https://${gitlab_fqdn}'
gitlab_pages['artifacts_server_url'] = 'https://${gitlab_fqdn}/api/v4'
gitlab_pages['access_control'] = true
gitlab_pages['listen_proxy'] = 'localhost:8090'

pages_nginx['enable'] = true
pages_nginx['listen_port'] = 80
pages_nginx['listen_https'] = false
pages_nginx['redirect_http_to_https'] = false

gitlab_pages['namespace_in_path'] = true

Observed Behavior

Working pages example:

Access: https://pages.subdomain1.example.com/my-static-site-af4708
Redirect to: https://pages.subdomain1.example.com/projects/auth?domain=https://pages.subdomain1.example.com/my-static-site-af4708&root_namespace_id=597&state=pMeCrL63onlIqf5Pb_aTrw==
Result: 200, lands on https://pages.subdomain1.example.com/my-static-site-af4708

Non-working pages example (acceptance environment):

Access: https://pages.acceptance.subdomain1.example.com/sdlc/plain-html
Redirect to: //pages.acceptance.subdomain1.example.com/sdlc/plain-html/ 
(with auth: https://pages.acceptance.subdomain1.example.com/projects/auth?domain=https://pages.acceptance.subdomain1.example.com/pages.acceptance.subdomain1.example.com&root_namespace_id=&state=iu0H4tlroKDBQeuKGnxptA==)
Redirect to: https://acceptance.subdomain1.example.com/oauth/authorize?client_id=ITLq2_W5dOCBg-Lhvco4uYLLXFH…
Result: 404, lands on https://pages.acceptance.subdomain1.example.com/pages.acceptance.subdomain1.example.com/plain-html-52bbb7/

Notice the domain parameter contains duplicated FQDN: pages.acceptance.subdomain1.example.com/pages.acceptance.subdomain1.example.com

Additional non-working example:

Access: https://pages.subdomain1.example.com/project2-efcad0
Result: https://pages.subdomain1.example.com/pages.subdomain1.example.com/project2-efcad0/

Impact

  • Both production and acceptance environments are affected
  • Behavior is inconsistent - some pages work, others don't
  • No clear pattern identified regarding which projects work vs. don't work
  • Not related to membership restrictions or unique domain settings
  • Pages can be under top-level groups or subgroups
  • Issue started at least with version 18.4.3

Additional Observations

  • The first redirect appears to come from GitLab nginx (returns root_namespace_id in auth string)
  • Some pages extract different namespaces from the URL
  • Example: project2-efcad0 gets namespace pages.subdomain2.subdomain1.example.com extracted, while my-static-site-af4708 gets namespace my-static-site-af4708 extracted