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