Hello, strange issue with the feature `HttpsRedire...
# ktor
v
Hello, strange issue with the feature
HttpsRedirect
, when I go to my home page http://{...}/login I have an error because ktor redirect my to https like an infinite loop...
📝 1
2
It’s really strange because in the dev console, I saw that https://{...} is also redirect
d
in addition to the HttpsRedirect, are you using manual redirections somewhere? https://ktor.io/servers/calls/responses.html#redirections or using an interceptor or feature that do redirections?
v
I used in one place redirect : get(“/”) { return@get call.respondRedirect(“/front”) }
When you go to / to redirect you to /front
d
do you use the oauth feature or something?
v
Yes I use this feature for google authentication
d
aha
I think the oauth perform redirects, so it could be related (or not), but could be related
specially because of the login route
v
But just to access the page to authentication, I have infinite loop...
d
if you access
https:// … /login
, it works?
only happens with http://?
v
Before authentication
No with all routes
d
have you configured oauth to have
https://
directly?
I would disable interceptors, features, one by one to see if something is interfering to locate the problem. Also you can just
return call.respondText("OK")
in the login route to not do anything else and then, and if it works, move that line down until the issue happens
to determine what’s causing the issue
v
oauth is configure to /login so I don’t know…
Yes but I can’t test https on localhost so It’s a little complicated … 😞
The strange thing is in dev console, I have request to https and the response is the redirection
In addition, For the first route, I just send the first page of my front app so no authentication issue,I really don’t understand
I remove all features but the problem still persists
d
can’t you use a self-signed certificate for that? And accept in your browser? (if you are using https, might worth investing some time in that)
have you tried to log things with the verbosest log level, to see if you see something strange?
v
No how I do this please (log) ? I can’t use the certificat because its my company and I don’t have access to it 😞
I enable log and nothing strange..
d
you don’t need that specific certificate
you need a self-signed one
v
I will try thanks
👍 1
So I succeed with self certificate. In this url https://localhost:8443/front I haven’t the problem with infinite loop
But on my prod server, I still have the problem so don’t know how to debug it…
d
uhm
let me ask
v
Thanks
d
After some troubleshooting we have figured out what was the problem and I’m going to update the documentation and the FAQ. For the record: There was a reverse-proxy/load balancer that was serving https, and making normal http requests to the ktor backend. The
HttpsRedirect
feature was installed but not the
XForwardedHeaderSupport
, thus the ktor backend believes that the request is always http and makes the redirect.
1