So I have an app that is hosted on AWS behind a network load balancer. I need to get the client’s IP address for some features of the site to run properly. Based on conversations with AWS it looks like the only way to get this information is by enabling the proxy protocol1 However, since the protocol prepends information to the http request it breaks the application whenever I enable it. (understandably) I wrote a parser for this protocol, in elixir but I am unsure how to hook into cowboy from phoenix in order to use it. 2 Based on my reading of the documentation I can change the adapter but there doesn’t seem to be much information surrounding interfacing with cowboy directly.
By the time I reach the handler the request has already been parsed by cowboy. I want to use the module I wrote to parse the proxy protocol and put the information in the request so I can initialize the conn correctly. Is there any way to do this? I am a bit flummoxed by how everything gets handled. There doesn’t seem to be an interface that I can hook into before Cowboy has done its work. Any help would be greatly appreciated.