Hello,
Is it possible to redirect http to https based on the X-Forwarded-Proto header?
Basically, I’d like to do something like the following in nginx:
if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
}
Thanks
Hello,
Is it possible to redirect http to https based on the X-Forwarded-Proto header?
Basically, I’d like to do something like the following in nginx:
if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
}
Thanks
Caddy can’t redirect based on header values, at least, not yet. I think @abiosoft wanted to work on this.
I see, thank you. I glanced at the code and it seems like one way to go would be to borrow the if condition code from the rewrite module and implement it in the redir module, but I might be missing something.
Yeah, that is what I am gonna do. The challenge has been to make it backward compitable and I seem to have found a way out.
When I am done, you will be able to do this.
redir {
if {>X-Forwarded-Proto} is http
/ https://{uri}
}
/
is catch all; could’ve been a subpath e.g. /subpath
. Same syntax as before, only if
is introduced.
Awesome! Thank you!
Just wanted to say since 0.9 dropped I am using this in production on Google Container Engine with their HTTP Load-Balancer and it works perfectly. Thanks again!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.