How to disable logging IP address?

AI-generated summary

Disabling IP address logging in Discourse is not a straightforward process due to the platform’s abuse prevention mechanisms. Despite discussions around EU GDPR compliance, no plugin has been developed to disable IP logging. However, there are alternative solutions. One approach is to use an external reverse proxy, such as NGINX, to mask IP addresses. As adriaan suggests, this can be achieved by setting the X-Real-IP to a fixed IP (127.0.0.1) in the NGINX configuration. This method is demonstrated in the provided code example.

Hello,
I successfully run discourse and now I’d like to disable logging users’ IP address.
There are many discussion of it as part of EU GDPR(2018, 2019), but I could not find the concrete solution for it.

https://meta.discourse.org/t/disabling-unnecessary-logging-for-gdpr-compliance/86301

I appreciate if someone guides me to find it!

Hello @codinghorror,
Is there any “How to” for your suggestion on Possible to not log user IP addresses? - #10 by codinghorror?
I see there were many demand on disabling IP logging in 2018 due to EU GDPR, so I expect there is simple solution already for this.

You need ip addresses to fight abuse, so I think that most people have decided that the way that Discourse manages up addresses is not in violation of gdpr. I think that no plugin emerged to do what you ask.

A simple solution is to use an external reverse proxy and don’t configure discourse to use the reverse proxy ip address (which happens by default).

For future searchers: you can use NGINX in front of the discourse instance, you can set the X-Real-IP to a fixed IP 127.0.0.1:

  location / {
    proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
    proxy_set_header Host $http_host;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Real-IP 127.0.0.1;
  }

Do not leave it out because you will get errors and the app will fail to start:

Completed 500 Internal Server Error in 149ms (Views: 11.1ms | ActiveRecord: 0.0ms | Allocations: 70970)
PG::InvalidTextRepresentation (ERROR:  invalid input syntax for type inet: "unix:"
LINE 7:     client_ip = 'unix:',
                        ^
)