Skip to content
9 changes: 9 additions & 0 deletions docs/sources/setup/install/helm/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -4418,6 +4418,15 @@ See values.yaml
<td><pre lang="json">
"{{ if .Values.loki.tenants }}proxy_set_header X-Scope-OrgID $remote_user;{{ end }}"
</pre>
</td>
</tr>
<tr>
<td>gateway.nginxConfig.locationSnippet</td>
<td>string</td>
<td>Allows appending custom configuration inside every location block, useful for authentication or setting headers that are not inherited from the server block, passed through the `tpl` function to allow templating.</td>
<td><pre lang="json">
""
</pre>
</td>
</tr>
<tr>
Expand Down
1 change: 1 addition & 0 deletions production/helm/loki/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Entries should include a reference to the pull request that introduced the chang
- [BUGFIX] Gateway Ingester endpoints points to inexistent service when zone aware replication are enabled [#17362](https://github.com/grafana/loki/pull/17362)
- [BUGFIX] add missing flush=true to preStop hook [#16063](https://github.com/grafana/loki/pull/16063)
- [BUGFIX] Fix setting X-Scope-OrgID header [#18414](https://github.com/grafana/loki/pull/18414)
- [ENHANCEMENT] Add possibility to configure location snippet in nginx config [#18105](https://github.com/grafana/loki/pull/18105)
- [BUGFIX] Set `use_thanos_objstore` to `true` in `storage_config` when `loki.storage.use_thanos_objstore` value is set to `true`. [#17024](https://github.com/grafana/loki/pull/17024)
- [ENHANCEMENT] Improve health probe helper templates [#18347](https://github.com/grafana/loki/pull/18347)
- [BUGFIX] Fix PDB settings for chunksCache and resultsCache [#18321](https://github.com/grafana/loki/pull/18321)
Expand Down
96 changes: 96 additions & 0 deletions production/helm/loki/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,9 @@ http {
{{- end }}

location = / {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
return 200 'OK';
auth_basic off;
}
Expand Down Expand Up @@ -899,122 +902,215 @@ http {

{{- if .Values.loki.ui.gateway.enabled }}
location ^~ /ui {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $distributorUrl }}$request_uri;
}
{{- end }}

# Distributor
location = /api/prom/push {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $distributorUrl }}$request_uri;
}
location = /loki/api/v1/push {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $distributorUrl }}$request_uri;
}
location = /distributor/ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $distributorUrl }}$request_uri;
}
location = /otlp/v1/logs {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $distributorUrl }}$request_uri;
}

# Ingester
location = /flush {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $ingesterUrl }}$request_uri;
}
location ^~ /ingester/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $ingesterUrl }}$request_uri;
}
location = /ingester {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
internal; # to suppress 301
}

# Ring
location = /ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $ingesterUrl }}$request_uri;
}

# MemberListKV
location = /memberlist {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $ingesterUrl }}$request_uri;
}

# Ruler
location = /ruler/ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /api/prom/rules {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location ^~ /api/prom/rules/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /loki/api/v1/rules {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location ^~ /loki/api/v1/rules/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /prometheus/api/v1/alerts {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /prometheus/api/v1/rules {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}

# Compactor
location = /compactor/ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $compactorUrl }}$request_uri;
}
location = /loki/api/v1/delete {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $compactorUrl }}$request_uri;
}
location = /loki/api/v1/cache/generation_numbers {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $compactorUrl }}$request_uri;
}

# IndexGateway
location = /indexgateway/ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $indexGatewayUrl }}$request_uri;
}

# QueryScheduler
location = /scheduler/ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $schedulerUrl }}$request_uri;
}

# Config
location = /config {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $ingesterUrl }}$request_uri;
}

{{- if and .Values.enterprise.enabled .Values.enterprise.adminApi.enabled }}
# Admin API
location ^~ /admin/api/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $backendUrl }}$request_uri;
}
location = /admin/api {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
internal; # to suppress 301
}
{{- end }}


# QueryFrontend, Querier
location = /api/prom/tail {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $queryFrontendUrl }}$request_uri;
}
location = /loki/api/v1/tail {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $queryFrontendUrl }}$request_uri;
}
location ^~ /api/prom/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $queryFrontendUrl }}$request_uri;
}
location = /api/prom {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
internal; # to suppress 301
}
location ^~ /loki/api/v1/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
proxy_pass {{ $queryFrontendUrl }}$request_uri;
}
location = /loki/api/v1 {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- tpl . $ | nindent 6 }}
{{- end }}
internal; # to suppress 301
}

Expand Down
2 changes: 2 additions & 0 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,8 @@ gateway:
# -- 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 }}
# -- Allows appending custom configuration inside every location block, useful for authentication or setting headers that are not inherited from the server block, passed through the `tpl` function to allow templating.
locationSnippet: ""
# -- 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
Loading