Changeset View
Changeset View
Standalone View
Standalone View
src/aphront/configuration/AphrontApplicationConfiguration.php
| Show First 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | final private function buildController() { | ||||
| $cluster_addresses = PhabricatorEnv::getEnvConfig('cluster.addresses'); | $cluster_addresses = PhabricatorEnv::getEnvConfig('cluster.addresses'); | ||||
| if ($cluster_addresses) { | if ($cluster_addresses) { | ||||
| $server_addr = idx($_SERVER, 'SERVER_ADDR'); | $server_addr = idx($_SERVER, 'SERVER_ADDR'); | ||||
| if (!$server_addr) { | if (!$server_addr) { | ||||
| if (php_sapi_name() == 'cli') { | if (php_sapi_name() == 'cli') { | ||||
| // This is a command line script (probably something like a unit | // This is a command line script (probably something like a unit | ||||
| // test) so it's fine that we don't have SERVER_ADDR defined. | // test) so it's fine that we don't have SERVER_ADDR defined. | ||||
| } else { | } else { | ||||
| throw new AphrontUsageException( | throw new AphrontMalformedRequestException( | ||||
| pht('No %s', 'SERVER_ADDR'), | pht('No %s', 'SERVER_ADDR'), | ||||
| pht( | pht( | ||||
| 'Phabricator is configured to operate in cluster mode, but '. | 'Phabricator is configured to operate in cluster mode, but '. | ||||
| '%s is not defined in the request context. Your webserver '. | '%s is not defined in the request context. Your webserver '. | ||||
| 'configuration needs to forward %s to PHP so Phabricator can '. | 'configuration needs to forward %s to PHP so Phabricator can '. | ||||
| 'reject requests received on external interfaces.', | 'reject requests received on external interfaces.', | ||||
| 'SERVER_ADDR', | 'SERVER_ADDR', | ||||
| 'SERVER_ADDR')); | 'SERVER_ADDR')); | ||||
| } | } | ||||
| } else { | } else { | ||||
| if (!PhabricatorEnv::isClusterAddress($server_addr)) { | if (!PhabricatorEnv::isClusterAddress($server_addr)) { | ||||
| throw new AphrontUsageException( | throw new AphrontMalformedRequestException( | ||||
| pht('External Interface'), | pht('External Interface'), | ||||
| pht( | pht( | ||||
| 'Phabricator is configured in cluster mode and the address '. | 'Phabricator is configured in cluster mode and the address '. | ||||
| 'this request was received on ("%s") is not whitelisted as '. | 'this request was received on ("%s") is not whitelisted as '. | ||||
| 'a cluster address.', | 'a cluster address.', | ||||
| $server_addr)); | $server_addr)); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | foreach ($sites as $candidate) { | ||||
| if ($site) { | if ($site) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (!$site) { | if (!$site) { | ||||
| $path = $request->getPath(); | $path = $request->getPath(); | ||||
| $host = $request->getHost(); | $host = $request->getHost(); | ||||
| throw new Exception( | throw new AphrontMalformedRequestException( | ||||
| pht('Site Not Found'), | |||||
| pht( | pht( | ||||
| 'This request asked for "%s" on host "%s", but no site is '. | 'This request asked for "%s" on host "%s", but no site is '. | ||||
| 'configured which can serve this request.', | 'configured which can serve this request.', | ||||
| $path, | $path, | ||||
| $host)); | $host), | ||||
| true); | |||||
| } | } | ||||
| $request->setSite($site); | $request->setSite($site); | ||||
| return $site; | return $site; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 144 Lines • Show Last 20 Lines | |||||