Can't login to registry due to "denied: access forbidden"

Docker’s http client is very dumb and while resolving an auth from http://gitlab.example.com/jwt/auth (gitlab behind reverse proxy) docker ignoring redirect to https. I found “exploit” like solution here