The discussion revolves around an issue where the last IP address shown in Discourse is the Reverse Proxy server’s IP address, instead of the user’s IP address. PhoenixPeca has researched and implemented reverse proxy settings but still faces the issue.
schleifer suggests that the nginx running in the container does not trust headers set by the proxy and provides a link to a relevant meta discussion. PhoenixPeca asks for guidance on resolving the issue.
riking proposes a solution involving adding set_real_ip_from <CIDR>; to the nginx.conf. schleifer provides an example of how to implement this.
Ivan_Rapekas suggests removing the same definitions from the docker file, modifying the app.yml file, and rebuilding. He provides an example of the modifications needed to resolve the issue.
I have researched quite a lot but nothing seems to work with me.
I have a discourse setup installed. And I have this remote reverse proxy server that acts as a HTTPS layer between the user and the main discourse server..
You only need the last part - inserting set_real_ip_from <CIDR>; to the nginx.conf. The other parts are more complicated to support Cloudflare adding new IPs.
Probably you need to remove the same definitions from docker, modify your app.yml and rebuild:
run:
- exec: echo "Beginning of custom commands"
- replace:
filename: /etc/nginx/conf.d/discourse.conf
from: $proxy_add_x_forwarded_for
to: $http_fastly_client_ip
global: true
- exec:
cmd:
- sed -i 's/client_max_body_size 10m ;/client_max_body_size 100m ;/g' /etc/nginx/conf.d/discourse.conf
- sed -i '/proxy_set_header X-Real-IP $remote_addr;/d' /etc/nginx/conf.d/discourse.conf
- sed -i '/proxy_set_header X-Forwarded-For $http_fastly_client_ip;/d' /etc/nginx/conf.d/discourse.conf
- sed -i '/proxy_set_header X-Forwarded-Proto $scheme;/d' /etc/nginx/conf.d/discourse.conf
- exec: echo "End of custom commands"
This block has 100m limit for max_body_size as well (the first sed command makes a replacement). The other sed commands remove lines from discourse.conf inside docker before container starts.