Skip to content

fix: helm - nginx tenants proxy headers #16953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/sources/setup/install/helm/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -4346,7 +4346,7 @@ See values.yaml
<td>string</td>
<td>Allows appending custom configuration to the http block, passed through the `tpl` function to allow templating</td>
<td><pre lang="json">
"{{ if .Values.loki.tenants }}proxy_set_header X-Scope-OrgID $remote_user;{{ end }}"
""
</pre>
</td>
</tr>
Expand Down
13 changes: 13 additions & 0 deletions production/helm/loki/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,10 @@ http {
resolver {{ .Values.global.dnsService }}.{{ .Values.global.dnsNamespace }}.svc.{{ .Values.global.clusterDomain }}.;
{{- end }}

{{- if .Values.loki.tenants }}
proxy_set_header X-Scope-OrgID $remote_user;
{{- end }}

{{- with .Values.gateway.nginxConfig.httpSnippet }}
{{- tpl . $ | nindent 2 }}
{{- end }}
Expand Down Expand Up @@ -983,11 +987,17 @@ http {
proxy_pass {{ $queryFrontendUrl }}$request_uri;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
{{- if .Values.loki.tenants }}
proxy_set_header X-Scope-OrgID $remote_user;
{{- end }}
}
location = /loki/api/v1/tail {
proxy_pass {{ $queryFrontendUrl }}$request_uri;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
{{- if .Values.loki.tenants }}
proxy_set_header X-Scope-OrgID $remote_user;
{{- end }}
}
location ^~ /api/prom/ {
proxy_pass {{ $queryFrontendUrl }}$request_uri;
Expand All @@ -1001,6 +1011,9 @@ http {
set $query_tags "noop=";
}
location ^~ /loki/api/v1/ {
{{- if .Values.loki.tenants }}
proxy_set_header X-Scope-OrgID $remote_user;
{{- end }}
# pass custom headers set by Grafana as X-Query-Tags which are logged as key/value pairs in metrics.go log messages
proxy_set_header X-Query-Tags "${query_tags},user=${http_x_grafana_user},dashboard_id=${http_x_dashboard_uid},dashboard_title=${http_x_dashboard_title},panel_id=${http_x_panel_id},panel_title=${http_x_panel_title},source_rule_uid=${http_x_rule_uid},rule_name=${http_x_rule_name},rule_folder=${http_x_rule_folder},rule_version=${http_x_rule_version},rule_source=${http_x_rule_source},rule_type=${http_x_rule_type}";
proxy_pass {{ $queryFrontendUrl }}$request_uri;
Expand Down
3 changes: 1 addition & 2 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1167,8 +1167,7 @@ gateway:
# -- Allows appending custom configuration to the server block
serverSnippet: ""
# -- Allows appending custom configuration to the http block, passed through the `tpl` function to allow templating
httpSnippet: >-
{{ if .Values.loki.tenants }}proxy_set_header X-Scope-OrgID $remote_user;{{ end }}
httpSnippet: ""
# -- Allows customizing the `client_max_body_size` directive
clientMaxBodySize: 4M
# -- Whether ssl should be appended to the listen directive of the server block or not.
Expand Down