diff --git a/src/Form/SamlauthConfigureForm.php b/src/Form/SamlauthConfigureForm.php
index 90d9b9b..fecaab6 100644
--- a/src/Form/SamlauthConfigureForm.php
+++ b/src/Form/SamlauthConfigureForm.php
@@ -417,6 +417,18 @@ class SamlauthConfigureForm extends ConfigFormBase {
       '#default_value' => $config->get('security_lowercase_url_encoding'),
     ];
 
+    $form['other'] = [
+      '#title' => $this->t('Other'),
+      '#type' => 'fieldset',
+    ];
+
+    $form['other']['samlauth_proxy_vars'] = array(
+      '#type' => 'checkbox',
+      '#title' => $this->t('Use the `Forwarded-For-*` headers'),
+      '#description' => $this->t('If this option is enabled, SAML Utils will use the `Forwarded-For-*` headers to check IDP response.'),
+      '#default_value' => $config->get('samlauth_proxy_vars'),
+    );
+
     return parent::buildForm($form, $form_state);
   }
 
@@ -511,6 +523,7 @@ class SamlauthConfigureForm extends ConfigFormBase {
       ->set('security_request_authn_context', $form_state->getValue('security_request_authn_context'))
       ->set('security_signature_algorithm', $form_state->getValue('security_signature_algorithm'))
       ->set('strict', $form_state->getValue('strict'))
+      ->set('samlauth_proxy_vars', $form_state->getValue('samlauth_proxy_vars'))
       ->save();
   }
 
diff --git a/src/SamlService.php b/src/SamlService.php
index 666526c..560f8c3 100644
--- a/src/SamlService.php
+++ b/src/SamlService.php
@@ -15,6 +15,7 @@ use Drupal\user\UserInterface;
 use Exception;
 use OneLogin_Saml2_Auth;
 use OneLogin_Saml2_Error;
+use OneLogin_Saml2_Utils;
 use Psr\Log\LoggerInterface;
 use RuntimeException;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -96,6 +97,11 @@ class SamlService {
     $this->logger = $logger;
     $this->eventDispatcher = $event_dispatcher;
     $this->privateTempStore = $temp_store_factory->get('samlauth');
+
+    if ($this->config->get('samlauth_proxy_vars')) {
+      // Use the `Forwarded-For-*` headers.
+      \OneLogin_Saml2_Utils::setProxyVars(TRUE);
+    }
   }
 
   /**
