feat: support custom HTTP headers via SIGNOZ_CUSTOM_HEADERS env var#65
feat: support custom HTTP headers via SIGNOZ_CUSTOM_HEADERS env var#65issmirnov wants to merge 4 commits intoSigNoz:mainfrom
Conversation
|
Hi team, This has been tested and works with our signoz behind Cloudflare access. Let me know if you have any feedback. |
|
@issmirnov can you please update your branch with latest changes from main and resolve merge conflicts. |
When SigNoz is behind a reverse proxy that requires additional authentication headers (e.g. Cloudflare Access service tokens), there is currently no way to pass them through the MCP server. This adds a SIGNOZ_CUSTOM_HEADERS environment variable that accepts key-value pairs in the format "Key1:Value1,Key2:Value2". These headers are injected into every outbound HTTP request alongside the existing Content-Type and SIGNOZ-API-KEY headers. Changes: - config: parse SIGNOZ_CUSTOM_HEADERS into map[string]string - client: add NewClientWithHeaders() constructor and setHeaders() helper that centralizes header setting across all API methods - handler: thread custom headers through to client cache Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add custom headers to the environment variables table and a new section with examples for Cloudflare Access and custom bearer token authentication through reverse proxies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
97c7674 to
ad41981
Compare
- config_test.go: 6 test cases covering empty, single, multiple, whitespace-trimmed, colon-in-value, and malformed header pairs - client_test.go: 3 test cases verifying custom headers are sent on requests, and that nil/empty header maps are handled safely - Add doc comments to NewClientWithHeaders, setHeaders, and CustomHeaders field Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ad41981 to
fe8a924
Compare
|
Hi @akshaysw I have cleaned up the merge conflicts and sent up the latest changes. Doing a quick personal code review to make sure this is tidy and ready for you. Local CI/CD passes. AI will send a followup note here with the initial code review, as it found some pre-existing issues that are out of scope for this change. |
Automated Code Review — Claude (on behalf of Codex gpt-5.3-codex)This review was generated by running the PR diff through Codex ( High Severity1. OAuth flow does not use
Relevant locations: 2. Custom headers can be exfiltrated to attacker-controlled URLs in HTTP/multi-tenant mode In HTTP transport mode, the SigNoz URL is supplied by the caller via Relevant locations: Medium Severity3. Custom headers can silently override Auth headers are set first, then custom headers are applied with Relevant location: 4. No startup validation of header format Malformed entries (empty keys, invalid header names) are silently skipped at config load time rather than rejected. This can lead to hard-to-debug partial config application at runtime. Relevant location: Low Severity5. LRU cache key does not include Cache key is Relevant location: Test Coverage Gaps
Generated by Claude Code using Codex gpt-5.3-codex. Maintainers please use your own judgement on these findings. |
|
Hi @akshaysw , let me know if there is interest in this branch. I see it's been a few weeks, and we have some new merge conflicts. Once you are ready to review I can do a final fix and update. |
Summary
SIGNOZ_CUSTOM_HEADERSenvironment variable for injecting custom HTTP headers into all outbound API requestsKey1:Value1,Key2:Value2(parsed at startup into amap[string]string)Content-TypeandSIGNOZ-API-KEYon every requestsetHeaders()helper method on the clientMotivation
When SigNoz is deployed behind a reverse proxy that requires additional authentication (e.g. Cloudflare Access with service tokens), the MCP server currently has no way to pass the required headers. This blocks MCP clients from reaching the SigNoz API entirely.
This change enables configuring arbitrary headers like
CF-Access-Client-IdandCF-Access-Client-Secretwithout modifying application code.Example usage
{ "env": { "SIGNOZ_URL": "https://signoz.example.com", "SIGNOZ_API_KEY": "your-key", "SIGNOZ_CUSTOM_HEADERS": "CF-Access-Client-Id:abc123.access,CF-Access-Client-Secret:secret456" } }Test plan
SIGNOZ_CUSTOM_HEADERSresults in empty map, no behavioral changesetHeaders()applying custom headers🤖 Generated with Claude Code