Trac behind Proxy

Trac uses REMOTE_ADDRESS to determine the client's IP address which can mislead the trac spam filters and flag a submission as spam. To change the behaviour, trac can be modified, to check the X-Real-IP and X-Forwarded-For headers by editing the trac/web/standalone.py file in the trac source and rebuilding trac:

--- trac/web/standalone.py.old	2011-12-12 14:01:33.546973494 +0000
+++ trac/web/standalone.py	2011-12-12 14:00:50.554973513 +0000
@@ -112,6 +112,11 @@
     server_version = 'tracd/' + VERSION
 
     def address_string(self):
+        # Get remote address of client if tracd is behind a proxy
+        ip = self.headers.get("X-Real-IP") or \
+             self.headers.get("X-Forwarded-For")
+        if ip:
+            return ip
         # Disable reverse name lookups
         return self.client_address[:2][0]

fuss/trac.txt ยท Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.