Hi; I need to read a different header for the client's IP address (HTTP_X_FORWARDED_FOR). Proxy servers & CDN's often rewrite the client's ip to thi header. So I cloned it and made my required changes (thanks git!). I'm happy to contribute back my changes if the community could use them. However, I'm seeing unexpected behavior with variable_get in this module.
I added a header text field to the restrict_by_ip admin form. The var gets set correctly but when I try to read variable_get my header name var in the module it falls back to the default value. Drush vget shows the expected value of the variable, as does the variable table in the database.
You can see an example of the problem by putting the following code on line 18 of restrict_by_ip.module. (I realize that role check doesn't use the error page, but you can see the variable_get failing this way).
error_log('restrict by ip error page' . variable_get('restrict_by_ip_error_page', 'default value'));
Could it be that by putting the call to session_inc in the settings file, the restrict_by_ip code is happening prior to the bootstrap process?
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | configurable-ip-header-1100150.patch | 5.98 KB | tricker |
Comments
Comment #1
tricker commentedmy final analysis seems to be the case. i had to look up the variable from the database because drupal issn't yet bootstrapped when this module's code is executed.
Comment #2
eidolon nightI'm having the exact same issue on my Pressflow/Varnish setup. You have code to share on how you fixed this?
Comment #3
tricker commentedHi Eidolon;
See the patch attached to this comment. It contains 3 items. (2 of which I submitted to other recent tickets)
1) configure this module to use another header to read Clients IP address
2) fix logic for restrict by role to support more than one IP/IP range at a time
3) bump up the size of the IP field from from 128 to 256 bit.
--Todd
Comment #4
james.wilson commentedSome of this patch has been reworked and all features added to the 6.x-3.x version.