Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/check/PhabricatorBaseURISetupCheck.php
Show All 11 Lines | protected function executeChecks() { | ||||
$host_header = AphrontRequest::getHTTPHeader('Host'); | $host_header = AphrontRequest::getHTTPHeader('Host'); | ||||
if (strpos($host_header, '.') === false) { | if (strpos($host_header, '.') === false) { | ||||
if (!strlen(trim($host_header))) { | if (!strlen(trim($host_header))) { | ||||
$name = pht('No "Host" Header'); | $name = pht('No "Host" Header'); | ||||
$summary = pht('No "Host" header present in request.'); | $summary = pht('No "Host" header present in request.'); | ||||
$message = pht( | $message = pht( | ||||
'This request did not include a "Host" header. This may mean that '. | 'This request did not include a "Host" header. This may mean that '. | ||||
'your webserver (like nginx or apache) is misconfigured so the '. | 'your webserver (like nginx or apache) is misconfigured so the '. | ||||
'"Host" header is not making it to Phabricator, or that you are '. | '"Host" header is not making it to %s, or that you are '. | ||||
'making a raw request without a "Host" header using a tool or '. | 'making a raw request without a "Host" header using a tool or '. | ||||
'library.'. | 'library.'. | ||||
"\n\n". | "\n\n". | ||||
'If you are using a web browser, check your webserver '. | 'If you are using a web browser, check your webserver '. | ||||
'configuration. If you are using a tool or library, check how the '. | 'configuration. If you are using a tool or library, check how the '. | ||||
'request is being constructed.'. | 'request is being constructed.'. | ||||
"\n\n". | "\n\n". | ||||
'It is also possible (but very unlikely) that some other network '. | 'It is also possible (but very unlikely) that some other network '. | ||||
'device (like a load balancer) is stripping the header.'. | 'device (like a load balancer) is stripping the header.'. | ||||
"\n\n". | "\n\n". | ||||
'Requests must include a valid "Host" header.'); | 'Requests must include a valid "Host" header.', | ||||
PhabricatorPlatformSite::getName()); | |||||
} else { | } else { | ||||
$name = pht('Bad "Host" Header'); | $name = pht('Bad "Host" Header'); | ||||
$summary = pht('Request has bad "Host" header.'); | $summary = pht('Request has bad "Host" header.'); | ||||
$message = pht( | $message = pht( | ||||
'This request included an invalid "Host" header, with value "%s". '. | 'This request included an invalid "Host" header, with value "%s". '. | ||||
'Host headers must contain a dot ("."), like "example.com". This '. | 'Host headers must contain a dot ("."), like "example.com". This '. | ||||
'is required for some browsers to be able to set cookies.'. | 'is required for some browsers to be able to set cookies.'. | ||||
"\n\n". | "\n\n". | ||||
'This may mean the base URI is configured incorrectly. You must '. | 'This may mean the base URI is configured incorrectly. You must '. | ||||
'serve Phabricator from a base URI with a dot (like '. | 'serve %s from a base URI with a dot (like '. | ||||
'"https://phabricator.mycompany.com"), not a bare domain '. | '"https://phabricator.mycompany.com"), not a bare domain '. | ||||
'(like "https://phabricator/"). If you are trying to use a bare '. | '(like "https://phabricator/"). If you are trying to use a bare '. | ||||
'domain, change your configuration to use a full domain with a dot '. | 'domain, change your configuration to use a full domain with a dot '. | ||||
'in it instead.'. | 'in it instead.'. | ||||
"\n\n". | "\n\n". | ||||
'This might also mean that your webserver (or some other network '. | 'This might also mean that your webserver (or some other network '. | ||||
'device, like a load balancer) is mangling the "Host" header, or '. | 'device, like a load balancer) is mangling the "Host" header, or '. | ||||
'you are using a tool or library to issue a request manually and '. | 'you are using a tool or library to issue a request manually and '. | ||||
'setting the wrong "Host" header.'. | 'setting the wrong "Host" header.'. | ||||
"\n\n". | "\n\n". | ||||
'Requests must include a valid "Host" header.', | 'Requests must include a valid "Host" header.', | ||||
$host_header); | $host_header, | ||||
PhabricatorPlatformSite::getName()); | |||||
} | } | ||||
$this | $this | ||||
->newIssue('request.host') | ->newIssue('request.host') | ||||
->setName($name) | ->setName($name) | ||||
->setSummary($summary) | ->setSummary($summary) | ||||
->setMessage($message) | ->setMessage($message) | ||||
->setIsFatal(true); | ->setIsFatal(true); | ||||
Show All 9 Lines | $summary = pht( | ||||
'The base URI for this install is not configured. Many major features '. | 'The base URI for this install is not configured. Many major features '. | ||||
'will not work properly until you configure it.'); | 'will not work properly until you configure it.'); | ||||
$message = pht( | $message = pht( | ||||
'The base URI for this install is not configured, and major features '. | 'The base URI for this install is not configured, and major features '. | ||||
'will not work properly until you configure it.'. | 'will not work properly until you configure it.'. | ||||
"\n\n". | "\n\n". | ||||
'You should set the base URI to the URI you will use to access '. | 'You should set the base URI to the URI you will use to access '. | ||||
'Phabricator, like "http://phabricator.example.com/".'. | '%s, like "http://phabricator.example.com/".'. | ||||
"\n\n". | "\n\n". | ||||
'Include the protocol (http or https), domain name, and port number if '. | 'Include the protocol (http or https), domain name, and port number if '. | ||||
'you are using a port other than 80 (http) or 443 (https).'. | 'you are using a port other than 80 (http) or 443 (https).'. | ||||
"\n\n". | "\n\n". | ||||
'Based on this request, it appears that the correct setting is:'. | 'Based on this request, it appears that the correct setting is:'. | ||||
"\n\n". | "\n\n". | ||||
'%s'. | '%s'. | ||||
"\n\n". | "\n\n". | ||||
'To configure the base URI, run the command shown below.', | 'To configure the base URI, run the command shown below.', | ||||
PhabricatorPlatformSite::getName(), | |||||
$base_uri_guess); | $base_uri_guess); | ||||
$this | $this | ||||
->newIssue('config.phabricator.base-uri') | ->newIssue('config.phabricator.base-uri') | ||||
->setShortName(pht('No Base URI')) | ->setShortName(pht('No Base URI')) | ||||
->setName(pht('Base URI Not Configured')) | ->setName(pht('Base URI Not Configured')) | ||||
->setSummary($summary) | ->setSummary($summary) | ||||
->setMessage($message) | ->setMessage($message) | ||||
->addCommand( | ->addCommand( | ||||
hsprintf( | hsprintf( | ||||
'<tt>phabricator/ $</tt> %s', | '<tt>phabricator/ $</tt> %s', | ||||
csprintf( | csprintf( | ||||
'./bin/config set phabricator.base-uri %s', | './bin/config set phabricator.base-uri %s', | ||||
$base_uri_guess))); | $base_uri_guess))); | ||||
} | } | ||||
} | } |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0