Skip to content
This repository was archived by the owner on Sep 7, 2021. It is now read-only.
This repository was archived by the owner on Sep 7, 2021. It is now read-only.

Redirect not working when behind load balancer #4

@Rhadros

Description

@Rhadros

If Kong is behind a load balancer a check for https is not working because it's always off. You should additionally check for the header value in X-Forwarded-Proto. If not "https" then you should redirect.
This should work behind a load balancer (at least it works on Heroku):

function HttpFilterHandler:access(conf)
  HttpFilterHandler.super.access(self)

  if ngx.var.https ~= "on" and ngx.var.http_x_forwarded_proto ~= "https" then
    return ngx.redirect("https://" .. ngx.var.host .. ngx.var.request_uri, ngx.HTTP_MOVED_PERMANENTLY)
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions