Route internal conduit calls if other hosts available

Summary:
Ref T2785

Looks for hosts in `conduit.servers` config and if any exist route any conduit calls through any one of the hosts.

Test Plan:
Make some curl calls to public methods (`conduit.ping`), watch the access log for two requests. Make some calls from the UI that require authentication, watch the access log a bit more.

Also ran the unit tests.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2785

Differential Revision: https://secure.phabricator.com/D5970
This commit is contained in:
Gareth Evans
2013-05-19 04:16:09 -07:00
committed by epriestley
parent a1a46656cb
commit 94e7878a57
7 changed files with 118 additions and 14 deletions

View File

@@ -113,18 +113,33 @@ abstract class AphrontApplicationConfiguration {
}
}
$path = $request->getPath();
$host = $request->getHost();
$base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri');
$prod_uri = PhabricatorEnv::getEnvConfig('phabricator.production-uri');
$file_uri = PhabricatorEnv::getEnvConfig('security.alternate-file-domain');
$path = $request->getPath();
$host = $request->getHost();
$base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri');
$prod_uri = PhabricatorEnv::getEnvConfig('phabricator.production-uri');
$file_uri = PhabricatorEnv::getEnvConfig(
'security.alternate-file-domain');
$conduit_uris = PhabricatorEnv::getEnvConfig('conduit.servers');
$uris = array_merge(
array(
$base_uri,
$prod_uri,
$file_uri,
),
$conduit_uris);
$host_match = false;
foreach ($uris as $uri) {
if ($host === id(new PhutilURI($uri))->getDomain()) {
$host_match = true;
break;
}
}
// NOTE: If the base URI isn't defined yet, don't activate alternate
// domains.
if ($base_uri &&
$host != id(new PhutilURI($base_uri))->getDomain() &&
$host != id(new PhutilURI($prod_uri))->getDomain() &&
$host != id(new PhutilURI($file_uri))->getDomain()) {
if ($base_uri && !$host_match) {
try {
$blog = id(new PhameBlogQuery())