geerlingguy / jeffgeerling-com

Drupal Codebase for JeffGeerling.com
https://www.jeffgeerling.com
GNU General Public License v2.0
38 stars 2 forks source link

Fix Drupal always getting server IP address for requests #108

Closed geerlingguy closed 4 years ago

geerlingguy commented 4 years ago

Apparently I forgot to configure the proxy settings from Nginx (since it's used for caching and PHP is running on internal port 81), so all requests look like they're coming from the same IP address, 104.236.203.61.

This causes two major problems:

  1. I can't log in anywhere because Drupal's flood controls block any login attempts due to bad actors filling up the flood table for that IP.
  2. Users can't comment because it looks like all comments come from the same IP, so that IP has been blocked by CleanTalk.
geerlingguy commented 4 years ago

Looks like I could use something like the following in settings.php:

<?php
$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = ['1.2.3.4', ...];
geerlingguy commented 4 years ago

Worked! I added that to my settings.local.php. Adding a note about it in the repo example.