Skip to content
Snippets Groups Projects

Issue #3188901: Support Amazon CloudFront

Files
2
@@ -15,7 +15,7 @@ function smart_ip_admin_settings($form, &$form_state) {
$smart_ip_source = variable_get('smart_ip_source', 'ipinfodb_service');
// MaxMind's Apache module mod_geoip, X-GeoIP-Country: XX header, EdgeScape and Cloudflare IP Geolocation don't support manual lookup and admin debug
if ($smart_ip_source == 'mod_geoip' || $smart_ip_source == 'x_header' || $smart_ip_source == 'es_header' || $smart_ip_source == 'cf_header') {
if ($smart_ip_source == 'mod_geoip' || $smart_ip_source == 'x_header' || $smart_ip_source == 'es_header' || $smart_ip_source == 'cf_header' || $smart_ip_source == 'aws_header') {
$can_query_ip = FALSE;
}
else {
@@ -163,6 +163,7 @@ function smart_ip_admin_settings($form, &$form_state) {
'x_header' => t('Use the X-GeoIP-Country: XX header, set by e.g. nginx'),
'es_header' => t('Use Akamai EdgeScape: your website must be using Akamai CDN and "EdgeScape Geolocation" option must be enabled at your !settings.', array('!settings' => l(t('Akamai settings'), 'https://control.akamai.com/apps/auth'))),
'cf_header' => t('Use Cloudflare IP Geolocation: your website must be using Cloudflare CDN and "IP Geolocation" option must be enabled at your !settings.', array('!settings' => l(t('Cloudflare settings'), 'https://www.cloudflare.com/cloudflare-settings'))),
'aws_header' => t('Use Amazon CloudFront: your website must be using AWS CloudFront and have the appropriate Geolocation headers whitelisted in your site policy.'),
),
'#default_value' => variable_get('smart_ip_source', 'ipinfodb_service'),
);
@@ -786,6 +787,9 @@ function smart_ip_admin_settings_validate($form, &$form_state) {
if ($form_state['values']['smart_ip_source'] == 'cf_header' && !isset($_SERVER['HTTP_CF_IPCOUNTRY'])) {
form_set_error('smart_ip_source', t('Your site is not using Cloudflare CDN or your Cloudflare "IP Geolocation" is disabled.'));
}
if ($form_state['values']['smart_ip_source'] == 'aws_header' && !isset($_SERVER['HTTP_CLOUDFRONT_VIEWER_COUNTRY'])) {
form_set_error('smart_ip_source', t('Your site is not using Amazon CloudFront or your "Geolocation" headers are not whitelisted.'));
}
if ($form_state['values']['smart_ip_source'] == 'ipinfodb_service' && empty($form_state['values']['smart_ip_ipinfodb_key'])) {
form_set_error('smart_ip_ipinfodb_key', t('Please provide IPInfoDB API key.'));
}
Loading