Skip to content

Commit 8ae394e

Browse files
authored
[Platform] Added HTTP to HTTPS redirection in nginx conf (#127)
* [Platform] Added HTTP to HTTPS redirection in nginx conf In a few of the SSO or OIDC integration, after integration, it redirects to the HTTP. And previously, we disabled the HTTP traffic totally once we enabled the TLS. But after these changes, it'll redirect the HTTP traffic to HTTPS in case TLS enabled deployment. * Added HSTS header and modified the proxy_set_header for proto
1 parent 470f0f4 commit 8ae394e

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

stable/yugaware/templates/configs.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ metadata:
155155
heritage: {{ .Values.helm2Legacy | ternary "Tiller" (.Release.Service | quote) }}
156156
data:
157157
default.conf: |
158+
{{- if .Values.tls.enabled }}
159+
# Ref: https://www.nginx.com/blog/http-strict-transport-security-hsts-and-nginx/
160+
server {
161+
listen {{ eq .Values.ip_version_support "v6_only" | ternary "[::]:8080" "8080" }};
162+
server_name {{ .Values.tls.hostname }};
163+
return 301 https://$host$request_uri;
164+
}
165+
{{- end }}
166+
158167
server {
159168
{{- if .Values.tls.enabled }}
160169
listen 8443 ssl;
@@ -164,13 +173,15 @@ data:
164173
ssl_protocols {{ include "validate_nginx_ssl_protocols" . }};
165174
{{- end }}
166175
server_name {{ .Values.tls.hostname }};
176+
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
167177
{{- else }}
168178
listen {{ eq .Values.ip_version_support "v6_only" | ternary "[::]:8080" "8080" }};
169179
server_name {{ .Values.tls.hostname }};
170180
{{- end }}
171181
proxy_http_version 1.1;
172182
proxy_set_header X-Real-IP $remote_addr;
173-
proxy_set_header X-Forwarded-For $remote_addr;
183+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
184+
proxy_set_header X-Forwarded-Proto $scheme;
174185
proxy_set_header Host $host;
175186

176187
location / {

stable/yugaware/templates/service.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ spec:
2424
{{- end }}
2525
{{- end }}
2626
ports:
27-
- name: ui
2827
{{- if .Values.tls.enabled }}
28+
- name: ui-tls
2929
port: 443
3030
targetPort: 8443
31-
{{- else }}
31+
{{- end }}
32+
- name: ui
3233
port: 80
3334
targetPort: 8080
34-
{{- end }}
3535
- name: metrics
3636
port: 9090
3737
selector:

0 commit comments

Comments
 (0)