I found an answer thanks to the question Django REST Framework pagination links do not use HTTPS
setting proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; in the nginx solves the problem.
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;