jerry

jerry

Retrieve remote IP address in a reverse proxy setup

Good day to you all.

I need assistance on an issue I am faced with.

I have an nginx reverse proxy, behind which is an Elixir application.

The challenge I have is that the only IP reaching the Elixir application is the local IP of the server on which the nginx reverse proxy resides.
Is there a way I can retrieve the remove IP address of the client application.

I need it to be able to secure my platform and only allow IPs whitelisted in my database.

I would be most grateful for your response.

Thanks.

Jerry

Most Liked

shanesveller

shanesveller

Making authz/authn decisions based only on client IP is extremely fraught with peril, so please be sure to continue to follow good practices and use a strong credential model as well. Treat client IP as something that can only deny access on a mismatch, rather than something that can allow access on a successful match.

I’ve seen another similar practice where organizations consider your ability to connect to the application, by being on VPN or otherwise being allowed through network-level whitelists, to be sufficient security, and in most cases this is both lazy and unsafe.

nesimtunc

nesimtunc

That was so complex. I checked out how Plausible Analytics how manage it and it’s super easy!

https://github.com/plausible/analytics/blob/3a1c9e67cd67d5cb1fec68a4dee34f8cd0e056fd/lib/plausible_web/remote_ip.ex

Where Next?

Popular in Questions Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement