Skip to content

Commit a992e1d

Browse files
authored
Add the possibility to configure the upstream protocol in the nginx configuration for the cortex upstream (#506)
* Add the possibility to configure the upstream protocol in the nginx for the cortex upstream Signed-off-by: Finn Evers <[email protected]> * update CHANGELOG.md Signed-off-by: Finn Evers <[email protected]> --------- Signed-off-by: Finn Evers <[email protected]>
1 parent 22c6b69 commit a992e1d

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## master / unreleased
44

5+
* [ENHANCEMENT] Add `nginx.config.upstream_protocol` field to configure the upstream protocol in the nginx configuration #506
6+
57
## 2.4.0 / 2024-07-18
68

79
* [CHANGE] Removed the default `livenessProbe` for store-gateway and compactor. You can still use a `livenessProbe` but we advise against it #502

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ Kubernetes: `^1.19.0-0`
439439
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;mainSnippet | string | `""` | arbitrary snippet to inject in the top section of the nginx config |
440440
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;serverSnippet | string | `""` | arbitrary snippet to inject in the server { } section of the nginx config |
441441
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;setHeaders | object | `{}` | |
442+
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;upstream_protocol | string | `"http"` | protocol for the communication with the upstream |
442443
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;verboseLogging | bool | `true` | Enables all access logs from nginx, otherwise ignores 2XX and 3XX status codes |
443444
| nginx.&ZeroWidthSpace;containerSecurityContext.&ZeroWidthSpace;enabled | bool | `true` | |
444445
| nginx.&ZeroWidthSpace;containerSecurityContext.&ZeroWidthSpace;readOnlyRootFilesystem | bool | `false` | |

templates/nginx/nginx-config.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,20 @@ data:
8181
8282
# Distributor Config
8383
location = /ring {
84-
proxy_pass http://{{ template "cortex.fullname" . }}-distributor.{{ $rootDomain }}$request_uri;
84+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-distributor.{{ $rootDomain }}$request_uri;
8585
}
8686
8787
location = /all_user_stats {
88-
proxy_pass http://{{ template "cortex.fullname" . }}-distributor.{{ $rootDomain }}$request_uri;
88+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-distributor.{{ $rootDomain }}$request_uri;
8989
}
9090
9191
location = /api/prom/push {
92-
proxy_pass http://{{ template "cortex.fullname" . }}-distributor.{{ $rootDomain }}$request_uri;
92+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-distributor.{{ $rootDomain }}$request_uri;
9393
}
9494
9595
## New Remote write API. Ref: https://cortexmetrics.io/docs/api/#remote-write
9696
location = /api/v1/push {
97-
proxy_pass http://{{ template "cortex.fullname" . }}-distributor.{{ $rootDomain }}$request_uri;
97+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-distributor.{{ $rootDomain }}$request_uri;
9898
}
9999
100100
{{- end }}
@@ -103,19 +103,19 @@ data:
103103
104104
# Alertmanager Config
105105
location ~ /api/prom/alertmanager/.* {
106-
proxy_pass http://{{ template "cortex.fullname" . }}-alertmanager.{{ $rootDomain }}$request_uri;
106+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-alertmanager.{{ $rootDomain }}$request_uri;
107107
}
108108
109109
location ~ /api/v1/alerts {
110-
proxy_pass http://{{ template "cortex.fullname" . }}-alertmanager.{{ $rootDomain }}$request_uri;
110+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-alertmanager.{{ $rootDomain }}$request_uri;
111111
}
112112
113113
location ~ /multitenant_alertmanager/status {
114-
proxy_pass http://{{ template "cortex.fullname" . }}-alertmanager.{{ $rootDomain }}$request_uri;
114+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-alertmanager.{{ $rootDomain }}$request_uri;
115115
}
116116
117117
location = /api/prom/api/v1/alerts {
118-
proxy_pass http://{{ template "cortex.fullname" . }}-alertmanager.{{ $rootDomain }}/api/v1/alerts;
118+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-alertmanager.{{ $rootDomain }}/api/v1/alerts;
119119
}
120120
121121
{{- end }}
@@ -124,15 +124,15 @@ data:
124124
125125
# Ruler Config
126126
location ~ /api/v1/rules {
127-
proxy_pass http://{{ template "cortex.fullname" . }}-ruler.{{ $rootDomain }}$request_uri;
127+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-ruler.{{ $rootDomain }}$request_uri;
128128
}
129129
130130
location ~ /ruler/ring {
131-
proxy_pass http://{{ template "cortex.fullname" . }}-ruler.{{ $rootDomain }}$request_uri;
131+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-ruler.{{ $rootDomain }}$request_uri;
132132
}
133133
134134
location ~ /api/prom/rules {
135-
proxy_pass http://{{ template "cortex.fullname" . }}-ruler.{{ $rootDomain }}$request_uri;
135+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-ruler.{{ $rootDomain }}$request_uri;
136136
}
137137
138138
{{- end }}
@@ -141,16 +141,16 @@ data:
141141
142142
# Query Config
143143
location ~ /api/prom/.* {
144-
proxy_pass http://{{ template "cortex.fullname" . }}-query-frontend.{{ $rootDomain }}$request_uri;
144+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-query-frontend.{{ $rootDomain }}$request_uri;
145145
}
146146
147147
## New Query frontend APIs as per https://cortexmetrics.io/docs/api/#querier--query-frontend
148148
location ~ ^{{.Values.config.api.prometheus_http_prefix}}/api/v1/(read|metadata|labels|series|query_range|query) {
149-
proxy_pass http://{{ template "cortex.fullname" . }}-query-frontend.{{ $rootDomain }}$request_uri;
149+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-query-frontend.{{ $rootDomain }}$request_uri;
150150
}
151151
152152
location ~ {{.Values.config.api.prometheus_http_prefix}}/api/v1/label/.* {
153-
proxy_pass http://{{ template "cortex.fullname" . }}-query-frontend.{{ $rootDomain }}$request_uri;
153+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-query-frontend.{{ $rootDomain }}$request_uri;
154154
}
155155
156156
{{- end }}
@@ -160,7 +160,7 @@ data:
160160
{{- range $org := compact .Values.nginx.config.auth_orgs | uniq }}
161161
location = /api/v1/push/{{ $org }} {
162162
proxy_set_header X-Scope-OrgID {{ $org }};
163-
proxy_pass http://{{ template "cortex.fullname" $ }}-distributor.{{ $rootDomain }}/api/v1/push;
163+
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" $ }}-distributor.{{ $rootDomain }}/api/v1/push;
164164
}
165165
{{- end }}
166166
{{- end }}

values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,8 @@ nginx:
11961196
mainSnippet: ""
11971197
# -- arbitrary snippet to inject in the server { } section of the nginx config
11981198
serverSnippet: ""
1199+
# -- protocol for the communication with the upstream
1200+
upstream_protocol: http
11991201
setHeaders: {}
12001202
# -- Optional list of [auth tenants](https://cortexmetrics.io/docs/guides/auth/) to set in the nginx config
12011203
auth_orgs: []

0 commit comments

Comments
 (0)