Skip to content

Add HTTP to HTTPS redirect in nginx gateway#24

Merged
maor-rozenfeld merged 1 commit intomainfrom
ci-175-add-http-to-https-redirect
Feb 20, 2026
Merged

Add HTTP to HTTPS redirect in nginx gateway#24
maor-rozenfeld merged 1 commit intomainfrom
ci-175-add-http-to-https-redirect

Conversation

@maor-rozenfeld
Copy link
Contributor

When global.publicUrl uses HTTPS, nginx now returns a 301 redirect for requests arriving over plain HTTP. The redirect is detected via the X-Forwarded-Proto header set by TLS-terminating load balancers and ingress controllers.

The redirect block is conditionally rendered only when global.publicUrl starts with https://, so it has no effect on HTTP-only deployments.

Resolves CI-175

When global.publicUrl uses HTTPS, nginx now returns a 301 redirect
for requests arriving over plain HTTP. The redirect is detected via
the X-Forwarded-Proto header set by TLS-terminating load balancers
and ingress controllers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 20, 2026 15:35
@linear
Copy link

linear bot commented Feb 20, 2026

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Helm chart’s nginx gateway configuration to conditionally redirect requests to HTTPS when global.publicUrl is configured with an https:// URL, using X-Forwarded-Proto to detect the original scheme behind a TLS-terminating proxy.

Changes:

  • Add a conditional nginx if block to return a permanent redirect to HTTPS when X-Forwarded-Proto indicates http.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{{- if include "openops.isHttps" . }}
# Redirect HTTP to HTTPS when behind a TLS-terminating load balancer
if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 301 may cause some clients/browsers to change non-GET/HEAD requests into a GET when following the redirect (dropping the request body). For an HTTP→HTTPS upgrade redirect this can break POST/PUT API calls; consider using a 308 (or 307) redirect to preserve method and body semantics.

Suggested change
return 301 https://$host$request_uri;
return 308 https://$host$request_uri;

Copilot uses AI. Check for mistakes.
{{- if include "openops.isHttps" . }}
# Redirect HTTP to HTTPS when behind a TLS-terminating load balancer
if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The redirect target uses $host, which is derived from the client-supplied Host header and also strips any port. This can lead to (a) redirects to an attacker-controlled host if Host is spoofed, and (b) broken redirects when global.publicUrl uses a non-443 HTTPS port. Prefer redirecting to the configured canonical host/port derived from global.publicUrl (or a trusted variable like $server_name if it matches the external hostname) rather than $host.

Suggested change
return 301 https://$host$request_uri;
return 301 https://$server_name$request_uri;

Copilot uses AI. Check for mistakes.
@maor-rozenfeld maor-rozenfeld merged commit 5665b87 into main Feb 20, 2026
7 checks passed
@maor-rozenfeld maor-rozenfeld deleted the ci-175-add-http-to-https-redirect branch February 20, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants