I’m working on a phoenix application, where there was a need to use reverse_proxy_plug
to forward a request to an elasticsearch server.
reverse_proxy_plug : A reverse proxy plug for proxying a request to another URL using HTTPoison
The above library provides the following function to add a forwarding route in the router file.
forward("/foo",
ReverseProxyPlug,
upstream: &SomeMod.func/1,
client_options: [
hackney: [
{:ssl_options,
[{:cacertfile,
Path.join([priv_dir, "tls", "elasticsearch-ca.pem"])
}]
}
]
])
The problem is that the path to a certificate file in ssl option requires the path to be absolute path. Since it is not known at the time of compilation. It takes the value from the system, where the release was build, that will not match with the deployment server. So was thinking if there would be a way to send a runtime value to this client_option.