Skip to content

Add support for custom HTTP headers in GitLab CI#124

Merged
lukeheath merged 4 commits into
fleetdm:mainfrom
avltree9798:gitlab-ci-custom-headers
Jun 20, 2026
Merged

Add support for custom HTTP headers in GitLab CI#124
lukeheath merged 4 commits into
fleetdm:mainfrom
avltree9798:gitlab-ci-custom-headers

Conversation

@avltree9798

Copy link
Copy Markdown
Contributor

Adds an optional FLEET_CUSTOM_HEADERS variable (comma-separated "Header:Value" pairs) applied to both the fleetctl version check (curl) and fleetctl (config set --custom-header, which persists to ~/.fleet/config so gitops uses them too).

This enables running GitOps against a Fleet server behind a reverse proxy or zero-trust access layer that requires extra request headers, e.g. a Cloudflare Access service token (CF-Access-Client-Id / CF-Access-Client-Secret). Defaults to empty, so existing pipelines are unaffected.

Adds an optional FLEET_CUSTOM_HEADERS variable (comma-separated "Header:Value" pairs) applied to both the fleetctl version check (curl) and fleetctl (config set --custom-header, which persists to ~/.fleet/config so gitops uses them too).

This enables running GitOps against a Fleet server behind a reverse proxy or zero-trust access layer that requires extra request headers, e.g. a Cloudflare Access service token (CF-Access-Client-Id / CF-Access-Client-Secret). Defaults to empty, so existing pipelines are unaffected.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a configurable way to include extra HTTP headers in the GitLab CI job that runs Fleet GitOps, intended to support Fleet servers behind proxies/zero-trust layers that require additional headers.

Changes:

  • Introduces a FLEET_CUSTOM_HEADERS CI variable and documents expected formatting.
  • Parses FLEET_CUSTOM_HEADERS into argument arrays for curl and fleetctl.
  • Applies the extra headers to the Fleet version check request and to fleetctl config set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .gitlab-ci.yml
Comment on lines +5 to +14
# Optional. Extra HTTP headers to send on every request to Fleet. They are applied to
# both the version check (curl) and all fleetctl commands (config set / gitops).
#
# Format: a comma-separated list of "Header:Value" pairs. Header values cannot contain
# commas. Leave empty to send no extra headers.
#
# Set the real value as a (masked) CI/CD variable in Settings > CI/CD > Variables, which
# overrides this default. Example for a Cloudflare Access service token:
# FLEET_CUSTOM_HEADERS: "CF-Access-Client-Id:<client-id>,CF-Access-Client-Secret:<client-secret>"
FLEET_CUSTOM_HEADERS: ""
Comment thread .gitlab-ci.yml
Comment on lines +31 to +37
if [[ -n "$FLEET_CUSTOM_HEADERS" ]]; then
IFS=',' read -ra _CUSTOM_HEADERS <<< "$FLEET_CUSTOM_HEADERS"
for _header in "${_CUSTOM_HEADERS[@]}"; do
CURL_HEADER_ARGS+=(--header "$_header")
FLEETCTL_HEADER_ARGS+=(--custom-header "$_header")
done
fi
Comment thread .gitlab-ci.yml
@getvictor

Copy link
Copy Markdown
Member

@avltree9798 This is a great idea. Can you also add this support for the GitHub CI?

Mirrors the GitLab CI change for the GitHub Actions path. FLEET_CUSTOM_HEADERS (comma-separated "Header:Value" pairs) is applied to the fleetctl version check (curl) and to fleetctl (config set --custom-header, which persists the headers so gitops uses them too) across the gitops-action, gitops-action-fleets, and gitops-action-rc composite actions, and is passed through the workflow env block.

This enables running GitOps against a Fleet server behind a reverse proxy or zero-trust access layer that requires extra request headers, e.g. a Cloudflare Access service token (CF-Access-Client-Id / CF-Access-Client-Secret). Unset/empty by default, so existing workflows are unaffected.
@avltree9798

Copy link
Copy Markdown
Contributor Author

This is done, can you please review this? @getvictor

@noahtalerman

Copy link
Copy Markdown
Member

This is done, can you please review this? @getvictor

Hey @lukeheath can you please take a look at this PR when you get the chance? I think Victor is OOO the next several days.

cc @avltree9798

@allenhouchins allenhouchins removed their request for review June 19, 2026 15:18
Comment thread .github/gitops-action-fleets/action.yml Outdated

@lukeheath lukeheath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@lukeheath lukeheath merged commit b7d2730 into fleetdm:main Jun 20, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants