I think http_proxy etc. variables are not effectively set when running sudo dnf.
For instance:
$ sudo dnf
does not give you a login shell .bash_profile is only run with login shells. On the other hand sudo is very picky about what environment variables are passed through. You could try $ sudo -i dnf
instead or $ sudo -E dnf
.
If you show us how you set http_proxy we might gain a better understanding of what is going on.
for dnf.conf there is a proxy=
directive.