Cannot connect WP Discourse to Discourse forum

From what I can figure out (this took a while), this is what’s causing the error:

It’s redirecting to Discourse. The plugin function that tests the connection to Discourse makes a request to GET /users/system.json when the settings page is saved. TheWordPress function wp_remote_get is used to make the request. It is set to follow a maximum of 5 redirections (that’s the default.) When HTTPS is enabled on the Discourse site, each time the function is run, it makes 5 requests to Discourse. Each request returns a 301 and a 549 status code. After five requests, the wp_remote_get function returns the ‘too many redirects’ error to WordPress. I don’t know why Discourse is returning the 549 status code.

Increasing the value for the allowable number of redirects just causes more requests to be made, but eventually results in the same error.

When HTTPS is not enabled on Discourse, everything runs fine.

The solution that working for me on the DigitalOcean setup is to install the php-curl extension and restart the server. Doing this makes the DigitalOcean 1 click WordPress install work with HTTPS enabled on both WordPress and Discourse. After enabling php-curl the request to Discourse is returning 200 and 2045.

It looks like what is going on is that the WordPress HTTP API functions (they are used throughout the plugin for making API calls to Discourse) have a function called _get_first_available_transport that first tries to use curl but falls back to streams if curl isn’t available.