I am using Sphinx in the AWS Cloud, would it be possible to add a configuration to admin/settings/sphinxsearch/settings so you can supply a hostname instead of an IP Address, when my instance restarts it gets an ip automatically assigned but the hostname always remains the same.

I think it would be relatively easy to resolve a hostname to an IP address and perform the same logic applied to IPs.

Comments

markus_petrux’s picture

I'll see what can I do... meanwhile, you could try something like the following, at the end of your settings.php

if (preg_match('#sphinxsearch_xmlpipe\.php$#', $_SERVER['SCRIPT_NAME'])) {
  $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
  if ($hostname == 'aws.cloud.example.com') {  // <---- setup this condition to match your needs.
    $conf['sphinxsearch_indexer_ips'] = $_SERVER['REMOTE_ADDR'];
  }
}

Hint: variables defined in settings.php override those defined in module settings panel.

Anyway, I'll try to add this possibility to the module itself.

markus_petrux’s picture

Title: Added ability to use a hostname instead of an ipaddress » Ability to use a hostname instead of an ipaddress?

There's another possible way... using several IP addresses (comma separated list) in the module settings panel (option "Sphinx indexer IP addresses"). Note that you can also use CIDR notation.

Do they offer a known IP range for your AWS cloud, or is that completely unknown to you?

sped2773’s picture

Had looked at this but it would potentially open it up to anyone using the AWS cloud, you don't currently seem to have a set range of IP addresses that are private to you.

markus_petrux’s picture

Status: Active » Closed (won't fix)

I'll soon post a method to invoke the XMLPipe generator from the command line, so it won't be necessary to check for IPs. Please, follow #327816: Ability to execute XMLPipe generator from PHP CLI