~sircmpwn/sr.ht-dev

meta.sr.ht: Correct value for addr to get real client IP even when behind apache reverse proxy v1 PROPOSED

Marc Grondin: 1
 Correct value for addr to get real client IP even when behind apache reverse proxy

 1 files changed, 1 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/9927/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH meta.sr.ht] Correct value for addr to get real client IP even when behind apache reverse proxy Export this patch

---
The audit tab was always showing 127.0.0.1 as the source no matter what.
Tried multiple settings in apache config RemoteIPHeader X-Forwarded-For,RemoteIPHeader X-Real-IP,RemoteIPHeader X-Real-IP,RemoteIPHeader X-Client-IP
All with same reults. Found this solution after much searching.
https://stackoverflow.com/questions/12770950/flask-request-remote-addr-is-wrong-on-webfaction-and-not-showing-real-user-ip#23281516
I don't know if this is ideal or not. Am open to other solutions but this get the correct client/remote IP to show.

 metasrht/audit.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/metasrht/audit.py b/metasrht/audit.py
index f96ad2e..8f35318 100644
--- a/metasrht/audit.py
+++ b/metasrht/audit.py
@@ -10,7 +10,7 @@ def audit_log(event_type, details=None, user=None):
        user = current_user
    if not user:
        return
    addr = request.headers.get("X-Real-IP") or request.remote_addr
    addr = request.access_route[-1]
    event = AuditLogEntry(user.id, event_type, ip_address(addr), details)
    db.session.add(event)

-- 
2.25.1
Thanks!

To git.sr.ht:~sircmpwn/meta.sr.ht
   744e3d7..6521a8c  master -> master