mirror of
https://github.com/laravel/valet.git
synced 2026-02-08 01:10:08 +01:00
Simplified HTTP_HOST rewriting
This commit is contained in:
committed by
Adam Wathan
parent
dbcbf1edc7
commit
745005dcae
@@ -53,6 +53,11 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
*/
|
||||
public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
{
|
||||
// Shortcut for getting the "local" hostname as the HTTP_HOST
|
||||
if (isset($_SERVER['HTTP_X_ORIGINAL_HOST']) && isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
|
||||
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
|
||||
}
|
||||
|
||||
return $sitePath.'/public/index.php';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,10 +45,6 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
*/
|
||||
public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
{
|
||||
if (isset($_SERVER['HTTP_X_ORIGINAL_HOST']) && isset($_SERVER['HTTP_X_INBOUND_HOST']) && $_SERVER['HTTP_X_ORIGINAL_HOST'] === $_SERVER['HTTP_HOST']) {
|
||||
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_INBOUND_HOST'];
|
||||
}
|
||||
|
||||
if (file_exists($frontControllerPath = $sitePath.'/web/app_dev.php')) {
|
||||
return $frontControllerPath;
|
||||
} elseif (file_exists($frontControllerPath = $sitePath.'/web/app.php')) {
|
||||
|
||||
12
server.php
12
server.php
@@ -97,18 +97,10 @@ function valet_support_xip_io($domain)
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite the HTTP host for Ngrok.
|
||||
* ngrok uses the X-Original-Host to store the forwarded hostname.
|
||||
*/
|
||||
if (isset($_SERVER['HTTP_X_ORIGINAL_HOST'])) {
|
||||
if (!isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
|
||||
if (isset($_SERVER['HTTP_X_ORIGINAL_HOST']) && !isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
|
||||
$_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_X_ORIGINAL_HOST'];
|
||||
}
|
||||
|
||||
// Store original HTTP_HOST so it can optionally be restored in a driver
|
||||
$_SERVER['HTTP_X_INBOUND_HOST'] = $_SERVER['HTTP_HOST'];
|
||||
|
||||
// Rewrite HTTP_HOST so it contains the hostname as entered by the visitor
|
||||
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_ORIGINAL_HOST'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user