This section most probably needs another approach as api_url is not scheme agnostic.

See https://httpd.apache.org/docs/2.2/mod/mod_proxy.html on what could be done (search for Dynamic determination of the scheme) on the page