Coldfront Labs

09/07/2009 - story

Drupal Quick Tip #7: Drupal behind a reverse proxy

I recently had to setup Drupal behind a reverse proxy server. (If you don't know what a reverse proxy server is, check it out on Wikipedia) One thing people may not realize about this sort of setup is if you want your logs for your visitors to show up properly, you need to change a setting inside your settings.php file. Here's how.
What you'll need: Drupal, a reverse proxy server
How to do it:

  1. Open your settings.php file for editing
  2. Scroll down until you see the "Variable overrides" section
    • roughly line 161
  3. Uncomment the " $conf = array ( " line
    • roughly line 173
  4. Scroll down  some more until you see " 'reverse_proxy' => TRUE" and uncomment that line
    • roughly line 202
  5. Scroll down again to " 'reverse_proxy_addresses' => array('a.b.c.d', ...), " and uncomment that line
    • roughly line 213
  6. Replace the "a.b.c.d" with the IP address of your reverse proxy server (you can have more than one if you want, just separate using commas)
  7. Scroll down one more time and uncomment the closing brackets for the " $conf " array
    • should be just below the reverse proxy address array variable, line 214
  8. Save and you're good to go.

What this does is tell Drupal to accept and trust the X-Forwarded-For value sent by your reverse proxy servers. Those are the values of the IP addresses of your visitors. Now your Drupal access logs should reflect your actual visitors and not just list your reverse proxy server as your only visitor. If you want more information on this, check the comments in your settings.php file.
 
Thanks!

Latest Tweets

  • #dcsf picture time! 19 weeks 1 day ago
  • What kind of team building stuff do you do remotely? (since not everyone is local) #magicteams 19 weeks 1 day ago
  • Really enjoying Drupalcon, learning so much! Need time to digest the info....and the awesome food! 19 weeks 2 days ago
  • Holy crap! http://tinyurl.com/yycqls6 Live NHL games on Boxee :-D #iamcanadian 19 weeks 3 days ago
  • Just getting to my second session at #dcsf and I've already lost my pen :-S 19 weeks 3 days ago

Poll

Do you plan on switching to Drupal 7 when it's released?:
Copyright © 2010