Back

[SOLVED] How to get the true ip for auth?

  • 0
  • Self Hosted
  • Web
  • Users
WildAnimal
20 May, 2023, 08:48

I noticed that the ip of session and activity are 172.25.0.1 for all users in my console. But my script create email session on the client side by user themself. So, what I'm puzzled about is why the obtained IP is a LAN IP but not the true ip. And more, I want to add some malicious IPs to the blacklist, what should I do.

TL;DR
Solution: The issue was that the user was getting the IP address of the reverse proxy instead of the true IP address. To solve this, they added the following configuration under the traefik command section in the docker-compse.yml file: ``` - --entryPoints.appwrite_web.forwardedHeaders.trustedIPs=172.25.0.1 - --entryPoints.appwrite_websecure.forwardedHeaders.trustedIPs=172.25.0.1 ``` This configuration tells traefik to trust the reverse proxy. Additionally, it was mentioned that if the user wants to add malicious IPs to the blacklist
D5
20 May, 2023, 09:15

It's not possible to get the device IP, only network IP

D5
20 May, 2023, 09:15

If other users that are not in the same network are showing the same IP, then something is wrongly configured

WildAnimal
20 May, 2023, 09:37

Yes, I mean network ip not device ip. If wrongly configured, what is it and how to fix it. Thanks.

D5
20 May, 2023, 09:40

Are you using cloudflare or any proxy service/WAF, etc?

D5
20 May, 2023, 20:22

@WildAnimal

WildAnimal
20 May, 2023, 22:04

Never

Drake
20 May, 2023, 23:40

I've noticed that when testing locally, you won't get the right IP Address, but when i hit Appwrite from a remote location, it picks up my IP fine.

Another thing...do you have any reverse proxy in front of Appwrite?

WildAnimal
21 May, 2023, 06:49

Yes, I had reversed proxy by nginx in front of appwrite console. Do I need to cancel this configuration, but I would like to access the appwrite console through port 80.

D5
21 May, 2023, 07:57

That's what I've asked

D5
21 May, 2023, 07:57

I think you're getting the reverse proxy IP address instead of the user IP address

safwan
21 May, 2023, 08:26

yep i think that's the expected behaviour with a reverse proxy setup. not sure though

D5
21 May, 2023, 08:27

Cloudflare and some reverse proxy should also send headers with the real IP, not sure if that works with appwrite

safwan
21 May, 2023, 08:28

I'm not super familiar with reverse proxying to be honest. need to look this up in more detaila

Drake
21 May, 2023, 14:37

Right so as D5 said, you might be getting the reverse proxy's IP. You'll need to tell traefik to trust that reverse proxy. See https://doc.traefik.io/traefik/routing/entrypoints/#forwarded-headers

WildAnimal
22 May, 2023, 00:53

Thank you all masters. It's working well after I added the following configuration under traefik command section in docker-compse.yml file :

TypeScript
      - --entryPoints.appwrite_web.forwardedHeaders.trustedIPs=172.25.0.1
      - --entryPoints.appwrite_websecure.forwardedHeaders.trustedIPs=172.25.0.1

Specially thank you @Steven and @D5

D5
22 May, 2023, 07:12

[SOLVED] How to get the true ip for auth?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more