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/ file in the trac source and rebuilding trac:

--- trac/web/	2011-12-12 14:01:33.546973494 +0000
+++ trac/web/	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: 2017/11/25 10:32 by office

Access website using Tor Access website using i2p

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