hiett/serverless-redis-http

Expose server on IPv6 interface

sorenhansendk opened this issue ยท 8 comments

First of all, thank you for developing such a useful tool to expose Redis to serverless environments. It's been incredibly helpful!

I am currently trying to deploy the server on Fly.io, which requires services to accept connections on IPv6. I've encountered an issue where the application does not seem to support listening on IPv6 addresses.

Could you please let me know if there is a way to configure the Elixir application to listen on a specific interface using an environment variable? Or if not, are there any plans to add IPv6 support in the near future?

Thank you.

Hi!

I did some googling and it seems that I have to add a line of code to make the http server listen on inet6 rather than 4. So it's not out-of-the-box right now, but it is a very small change required to get it to work.

I have been planning to do some housekeeping and finish some of my PRs on this project this weekend, this is absolutely something I can sneak in.

For reference, it just needs net: :inet6 added next to the port in

{
Plug.Cowboy,
scheme: :http,
plug: Srh.Http.BaseRouter,
options: [
port: @port
]
}
-- that small of a change!

Have this implemented in that PR, going to update the documentation and then make a release.

@sorenhansendk this is available via the image hiett/serverless-redis-http:0.0.10-alpha. Simply set env var SRH_IPV6 = true.

I am just doing some more comprehensive testing before I release it as the latest tag, but will be in a couple hours!

this is now released under the latest tag. Let me know if all is good!

Hi @hiett, thank you for the quick fix regarding the IPv6 listener. It's working great!

Do you know if there should be any issues with connections to IPv6 addresses in the SRH_CONNECTION_STRING?

I'm encountering an error when I try to connect to a Redis (Dragonfly) instance hosted on an IPv6 address:

WARNING: SRH was unable to connect to the Redis server. Please make sure it is running, and the connection information is correct. SRH ID: env_config_connection

I have confirmed that there is a connection to the instance using curl on the same address, and that is working perfectly.

It looks like there also has to be socket options provided to the Redix (redis driver used here) instance to use IPv6, and this is a common thing for people using fly.io: whatyouhide/redix#222

I will see if there is a nice way for me to add support for this. Especially since it's likely behind a local DNS name, it seems a bit counter-intuitive if I have to require manual IPv6 configuration for the SRH server. I will do some thinking. I can likely resolve the IP myself and check if it is IPv6 or not

Ok, thank you @hiett. Should I create a new issue on this one?

In the Redis library I use in Node.js I need to provide the connection string like this, if I connect on IPv6:

redis://{username}:{password}@[hostname]:6379

And if I would like to connect to a instance on IPv4, I remove the brackets like this:

redis://{username}:{password}@hostname:6379

Yeah - let's open a new issue to drill down and fix this up, I'll let you create that one