From b10aaff45962b27289a8274d72ef9ee68a5f5c9e Mon Sep 17 00:00:00 2001 From: mercury Date: Sun, 22 Sep 2024 01:06:02 +0400 Subject: [PATCH] fix domain for cdn --- app/bot.php | 15 +++++++-------- config/nginx.conf | 2 ++ config/nginx_default.conf | 2 ++ version | 2 ++ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/bot.php b/app/bot.php index 92d74e4..d0a8692 100644 --- a/app/bot.php +++ b/app/bot.php @@ -4729,7 +4729,7 @@ DNS-over-HTTPS with IP: { $type = $_GET['t'] == 's' ? 'v2ray' : 'sing'; $pac = $this->getPacConf(); - $domain = $this->getDomain($pac['transport'] == 'Websocket'); + $domain = $_GET['cdn'] ?: ($_SERVER['SERVER_NAME'] ?: $this->getDomain($pac['transport'] == 'Websocket')); $xr = $this->getXray(); $scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https'; $hash = substr(md5($this->key), 0, 8); @@ -4810,7 +4810,7 @@ DNS-over-HTTPS with IP: switch ($_GET['t']) { case 's': - $c['outbounds'][0]['settings']['vnext'][0]['address'] = $_GET['cdn'] ?: $domain; + $c['outbounds'][0]['settings']['vnext'][0]['address'] = $domain; $c['outbounds'][0]['settings']['vnext'][0]['users'][0] = [ 'id' => $uid, 'encryption' => 'none', @@ -4824,7 +4824,7 @@ DNS-over-HTTPS with IP: ], "tlsSettings" => [ "allowInsecure" => false, - "serverName" => $_GET['cdn'] ?: $domain, + "serverName" => $domain, "fingerprint" => "chrome" ] ]; @@ -4862,7 +4862,7 @@ DNS-over-HTTPS with IP: $c['dns']['servers'][0]['address'] = "https://$domain/dns-query/$uid"; } - $c['outbounds'][0]['server'] = $_GET['cdn'] ?: $domain; + $c['outbounds'][0]['server'] = $domain; $c['outbounds'][0]['uuid'] = $uid; if ($pac['transport'] == 'Websocket') { unset($c['outbounds'][0]['tls']['reality']); @@ -4871,7 +4871,7 @@ DNS-over-HTTPS with IP: "type" => "ws", "path" => "/ws" ]; - $c['outbounds'][0]['tls']['server_name'] = $_GET['cdn'] ?: $domain; + $c['outbounds'][0]['tls']['server_name'] = $domain; } else { unset($c['outbounds'][0]["transport"]); $c['outbounds'][0]['flow'] = 'xtls-rprx-vision'; @@ -4891,7 +4891,7 @@ DNS-over-HTTPS with IP: $c['route']['rules'] = array_values($c['route']['rules']); $c['route'] = $this->addRuleSet($c['route']); $c['route'] = $this->addPackageRule($c['route']); - $c['route'] = $this->createRuleSet($c['route'], $uid); + $c['route'] = $this->createRuleSet($c['route'], $uid, $domain); $c['route'] = $this->clearEmptyRules($c['route']); break; } @@ -4948,10 +4948,9 @@ DNS-over-HTTPS with IP: return $route; } - public function createRuleSet($route, $uid) + public function createRuleSet($route, $uid, $domain) { $pac = $this->getPacConf(); - $domain = $this->getDomain(); $scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https'; $hash = substr(md5($this->key), 0, 8); diff --git a/config/nginx.conf b/config/nginx.conf index 6a449b3..b2f4808 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -48,6 +48,7 @@ http { } location /pac { access_log /logs/nginx_pac_access; + proxy_set_header Host $http_host; proxy_pass http://php; } location /tlgrm { @@ -139,6 +140,7 @@ http { # } # location /pac { # access_log /logs/nginx_pac_access; + # proxy_set_header Host $http_host; # proxy_pass http://php; # } # location ~\.well-known { diff --git a/config/nginx_default.conf b/config/nginx_default.conf index 6a449b3..b2f4808 100644 --- a/config/nginx_default.conf +++ b/config/nginx_default.conf @@ -48,6 +48,7 @@ http { } location /pac { access_log /logs/nginx_pac_access; + proxy_set_header Host $http_host; proxy_pass http://php; } location /tlgrm { @@ -139,6 +140,7 @@ http { # } # location /pac { # access_log /logs/nginx_pac_access; + # proxy_set_header Host $http_host; # proxy_pass http://php; # } # location ~\.well-known { diff --git a/version b/version index fd5133d..424da8e 100644 --- a/version +++ b/version @@ -1,3 +1,5 @@ +22.09.2024 v1.56.2 +- фикс разных доменов при указании cdn для xray 19.09.2024 v1.56.1 - cdn для xray 17.09.2024 v1.55