Config.assume_ssl - could not login to devise

config.assume_ssl describes exactly my use-case, but when enabling, I could not logon to devise. This is what happens:

The reverse proxy then does nothing with that Location, because it does not match with where the redirection did go. So the client browser ends up with an intranet redirect that it cannot digest in any way.

I did rewrite that location header in the r-proxy. But then the next error appeared and login still didn’t work:

HTTP Origin header (http://app.intranet:8765) didn't match request.base_url (https://app.intranet:8765)

This can also be rewritten, but at that point I got bored: how many more might appear?