In my case leaving it as written, it was showing 127.0.0.1 for all users, even though in nginx logs the user ip was correctly logged.
Applying @varun21 's answer Serve Discourse from a subfolder (path prefix) instead of a subdomain - #111 by varun21 solved the issue.
Thank you @varun21