I have a Wildfly behind a load balancer, the connection between them is always HTTP. The connection between the client and the load balancer can be HTTP or HTTPS.
The load balancer sets a header (X-Forwarded-Proto) to let the Wildfly know which protocol the client is using.
I'm trying to write an Undertow rule to redirect to HTTPS taking into account all the conditions above.
This is one of my more successful tries (this rule is written in the undertow-handlers.conf file and it's the only thing in that file):
regex('/(.*)') and regex(pattern='http',value='%{i,X-Forwarded-Proto}',full-match=true)-> redirect(https://server.com/${1})
When the client try to access an url like: http://server.com/myapp is redirected to https://server.com, but the path /myapp is missing.
How can I fix my Undertow rule to keep the full path?