Skip to content

GitLab Pages daemon crashes (FATAL) when GITLAB_PAGES_ACCESS_CONTROL=true: {{GITLAB_RELATIVE_URL_ROOT}} left unsubstituted in gitlab-pages-config #3263

@Joe0rtiz

Description

@Joe0rtiz

Summary

When GITLAB_PAGES_ENABLED=true and GITLAB_PAGES_ACCESS_CONTROL=true, the generated gitlab-pages-config keeps a literal, unsubstituted {{GITLAB_RELATIVE_URL_ROOT}} token, producing an invalid internal-gitlab-server URL. The gitlab-pages daemon then crashes on every start.

Environment

  • Image: sameersbn/gitlab:18.11.2 (logic is also present in master)
  • Pages enabled with access control, no relative URL root (GitLab served at domain root)

Symptom

gitlab-pages is FATAL in supervisorctl status, and /var/log/gitlab/gitlab/gitlab-pages.log shows:

ERROR could not create domains config source: parse
"http://127.0.0.1:8080{{GITLAB_RELATIVE_URL_ROOT}}": invalid port
":8080{{GITLAB_RELATIVE_URL_ROOT}}" after host

/home/git/gitlab/gitlab-pages-config contains:

internal-gitlab-server=http://127.0.0.1:8080{{GITLAB_RELATIVE_URL_ROOT}}

Root cause

In assets/runtime/functions, configure_gitlab_pages() substitutes the config differently per branch. The access-control-disabled branch passes GITLAB_RELATIVE_URL_ROOT to update_template:

update_template ${GITLAB_PAGES_CONFIG} \
    GITLAB_RELATIVE_URL_ROOT \
    GITLAB_PAGES_NAMESPACE_IN_PATH \
    GITLAB_PAGES_LOG_VERBOSE \
    GITLAB_INSTALL_DIR

…but the access-control-enabled branch does not:

update_template ${GITLAB_PAGES_CONFIG} \
    GITLAB_PAGES_ACCESS_CLIENT_ID \
    GITLAB_PAGES_ACCESS_CLIENT_SECRET \
    GITLAB_PAGES_ACCESS_REDIRECT_URI \
    GITLAB_PAGES_ACCESS_SECRET \
    GITLAB_PAGES_ACCESS_CONTROL_SERVER \
    GITLAB_PAGES_NAMESPACE_IN_PATH \
    GITLAB_PAGES_LOG_VERBOSE \
    GITLAB_INSTALL_DIR

So with access control on, the {{GITLAB_RELATIVE_URL_ROOT}} placeholder in the template is never replaced.

Proposed fix

Add GITLAB_RELATIVE_URL_ROOT to the update_template argument list in the access-control-enabled branch (matching the disabled branch). With an empty GITLAB_RELATIVE_URL_ROOT this yields a valid internal-gitlab-server=http://127.0.0.1:8080.

Workaround

Strip the token after config generation and restart the daemon:

sed -i 's|{{GITLAB_RELATIVE_URL_ROOT}}||g' /home/git/gitlab/gitlab-pages-config
supervisorctl restart gitlab-pages

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions