Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: Session object store incorrect info #4893

Closed
2 tasks done
usamashafiqs opened this issue Dec 21, 2022 · 6 comments
Closed
2 tasks done

馃悰 Bug Report: Session object store incorrect info #4893

usamashafiqs opened this issue Dec 21, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@usamashafiqs
Copy link

馃憻 Reproduction steps

Session showing me my host server IP and Location instead of logged in user.

Screenshot 2022-12-21 193413

馃憤 Expected behavior

Session should show logged in user IP and Location.

馃憥 Actual Behavior

Session showing me my server IP and Location instead of logged in user.

馃幉 Appwrite version

Version 1.1.x

馃捇 Operating system

Linux

馃П Your Environment

No response

馃憖 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

馃彚 Have you read the Code of Conduct?

@usamashafiqs usamashafiqs added the bug Something isn't working label Dec 21, 2022
@stnguyen90
Copy link
Contributor

@usamashafiqs thanks for raising this issue! 馃檹馃徏 Do you have a reverse proxy in front of Appwrite?

@stnguyen90 stnguyen90 self-assigned this Dec 21, 2022
@usamashafiqs
Copy link
Author

I did not have any reverse proxy in front of Appwrite. But appwrite already have traefik as reverse proxy.

@stnguyen90
Copy link
Contributor

But appwrite already have traefik as reverse proxy.

Traefik should be fine and shouldn't interfere with the IP address that is collected.

Do you have anything else running on the server? Do you have anything else in front of Appwrite? Any other information you can provide about your infrastructure/architecture?

@usamashafiqs
Copy link
Author

usamashafiqs commented Dec 22, 2022

Only appwrite instance is running on server.
=> Cloudflare dns
=> Ubuntu 22.04.1 LTS
=> Docker
=> Appwrite

Screenshot 2022-12-22 at 10 56 57 PM

@stnguyen90
Copy link
Contributor

The problem could be Cloudflare proxy. Since the request some from Cloudflare proxy, Appwrite uses that as the source IP address. In order to get Appwrite to use the IP address before Cloudflare, you'll have to tell Appwrite to trust Cloudflare and use the IP passed in the header using the forwardedHeaders option.

I would recommend creating a docker-compose.override.yml file in the same folder as your Appwrite docker-compose.yml file if you haven't already and adding this:

services:
  traefik:
    command:
      - --providers.file.directory=/storage/config
      - --providers.file.watch=true
      - --providers.docker=true
      - --providers.docker.exposedByDefault=false
      - --providers.docker.constraints=Label(`traefik.constraint-label-stack`,`appwrite`)
      - --entrypoints.appwrite_web.address=:80
      - --entrypoints.appwrite_websecure.address=:443
      - --entrypoints.appwrite_web.forwardedHeaders.trustedIPs=<IP Address of Cloudflare>
      - --entrypoints.appwrite_websecure.forwardedHeaders.trustedIPs=<IP Address of Cloudflare>

The list of Cloudflare IP Addresses can be found here.

After creating this file, run docker compose up -d to apply the changes.

Alternatively, you can trust all IPs by putting this instead of the trustedIPs:

      - --entrypoints.appwrite_web.forwardedHeaders.insecure
      - --entrypoints.appwrite_websecure.forwardedHeaders.insecure

@usamashafiqs
Copy link
Author

@stnguyen90 thanks! It worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants