While you can, of course, host your own “libravatar” instance, you can also make use of the exemplar of Libravatar, https://libravatar.org, exactly as you would Gravatar. No need to host your own. That Libravatar service is just like Gravatar, except with more freedom attached…
In theory, you should be able to swap the libravatar.org URL for the gravatar.com URL in Discourse’s configuration. I’m new to Discourse, so I haven’t seen if it’s an admin-editable URL, or if it has to be done in the filesystem (I suspect the latter) - it’d be very cool if this was abstracted into the admin settings (along with switches for the explanatory links that currently lead users to Gravatar.com) interface. I’d prefer to use Libravatar over Gravatar.
By the way, if you create a Libravatar account, it will help you import your existing Gravatar.com email addresses and associated images, so it’s an easy transition.