Skip to content

How to capture client IP address #3305

Answered by laurenceisla
slloyd88 asked this question in Q&A
Discussion options

You must be logged in to vote

PostgREST only shows the client's IP it in the logs, as you have mentioned. In order for you to handle the IP, your reverse proxy needs to explicitly set the x-forwarded-for header.

For instance, if you use Nginx as a reverse proxy, you can follow the example in the docs and add the header inside the location:

    location /api/ {
      default_type  application/json;
      proxy_hide_header Content-Location;
      add_header Content-Location  /api/$upstream_http_content_location;
      proxy_set_header  Connection "";
      proxy_http_version 1.1;
      proxy_pass http://postgrest/;
      # setting the header:
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

Only …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wolfgangwalther
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants