Refactor Server.php to improve default 404 redirect setup
This commit is contained in:
parent
21a5b4ce80
commit
480ae3de8a
1 changed files with 4 additions and 8 deletions
|
|
@ -165,14 +165,13 @@ public function setupDefault404Redirect()
|
||||||
$dynamic_conf_path = $this->proxyPath().'/dynamic';
|
$dynamic_conf_path = $this->proxyPath().'/dynamic';
|
||||||
$proxy_type = $this->proxyType();
|
$proxy_type = $this->proxyType();
|
||||||
$redirect_url = $this->proxy->redirect_url;
|
$redirect_url = $this->proxy->redirect_url;
|
||||||
ray($proxy_type);
|
|
||||||
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
|
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
|
||||||
$default_redirect_file = "$dynamic_conf_path/default_redirect_404.yaml";
|
$default_redirect_file = "$dynamic_conf_path/default_redirect_404.yaml";
|
||||||
} elseif ($proxy_type === 'CADDY') {
|
} elseif ($proxy_type === ProxyTypes::CADDY->value) {
|
||||||
$default_redirect_file = "$dynamic_conf_path/default_redirect_404.caddy";
|
$default_redirect_file = "$dynamic_conf_path/default_redirect_404.caddy";
|
||||||
}
|
}
|
||||||
if (empty($redirect_url)) {
|
if (empty($redirect_url)) {
|
||||||
if ($proxy_type === 'CADDY') {
|
if ($proxy_type === ProxyTypes::CADDY->value) {
|
||||||
$conf = ':80, :443 {
|
$conf = ':80, :443 {
|
||||||
respond 404
|
respond 404
|
||||||
}';
|
}';
|
||||||
|
|
@ -242,7 +241,7 @@ public function setupDefault404Redirect()
|
||||||
$conf;
|
$conf;
|
||||||
|
|
||||||
$base64 = base64_encode($conf);
|
$base64 = base64_encode($conf);
|
||||||
} elseif ($proxy_type === 'CADDY') {
|
} elseif ($proxy_type === ProxyTypes::CADDY->value) {
|
||||||
$conf = ":80, :443 {
|
$conf = ":80, :443 {
|
||||||
redir $redirect_url
|
redir $redirect_url
|
||||||
}";
|
}";
|
||||||
|
|
@ -258,9 +257,6 @@ public function setupDefault404Redirect()
|
||||||
"echo '$base64' | base64 -d | tee $default_redirect_file > /dev/null",
|
"echo '$base64' | base64 -d | tee $default_redirect_file > /dev/null",
|
||||||
], $this);
|
], $this);
|
||||||
|
|
||||||
if (config('app.env') == 'local') {
|
|
||||||
ray($conf);
|
|
||||||
}
|
|
||||||
if ($proxy_type === 'CADDY') {
|
if ($proxy_type === 'CADDY') {
|
||||||
$this->reloadCaddy();
|
$this->reloadCaddy();
|
||||||
}
|
}
|
||||||
|
|
@ -908,7 +904,7 @@ public function ip(): Attribute
|
||||||
{
|
{
|
||||||
return Attribute::make(
|
return Attribute::make(
|
||||||
get: function ($value) {
|
get: function ($value) {
|
||||||
return preg_replace('/[^0-9a-zA-Z.-]/', '', $value);
|
return preg_replace('/[^0-9a-zA-Z.:%-]/', '', $value);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue