Skip to content

Commit 3895867

Browse files
committed
fix(relay): remove same-server localhost detection, always use hub URL from enrollment
1 parent 59d69b9 commit 3895867

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

config/relay.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
/**
44
* Relay tunnel configuration.
55
*
6-
* For servers co-located with the hub, use 127.0.0.1 to avoid hairpin NAT issues.
7-
* For remote servers, use the hub's public hostname with wss:// protocol.
6+
* The hub_relay_ws_url is normally derived from the enrollment's hub_base_url
7+
* at start time via RelayConfig::withAutoEnable(). Set it here only for
8+
* unusual deployment scenarios that cannot be handled by enrollment.
89
*
910
* @package Phlix\Config
1011
* @since 0.12.0
@@ -19,9 +20,9 @@
1920

2021
// Hub server-tunnel WS endpoint (Phlix\Hub\Relay\RelayWorker, default :8802).
2122
// The enrollment JWT is sent in the JSON HELLO body, not as an auth header.
22-
// Use ws://127.0.0.1:8802 if hub and server are co-located (avoids hairpin NAT).
23-
// Use wss://hub.phlix.interserver.net:8802 for remote servers.
24-
'hub_relay_ws_url' => 'ws://127.0.0.1:8802',
23+
// When empty, the URL is derived from the enrollment's hub_base_url via
24+
// RelayConfig::withAutoEnable() at RelayConsumer start time.
25+
'hub_relay_ws_url' => '',
2526

2627
// This server's own local HTTP listener that relayed client bytes are piped to.
2728
'local_http_address' => '127.0.0.1:8096',

src/Common/Container/Providers/HubServicesProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ static function (ContainerInterface $c): RelayConsumer {
194194
$enrollment = $hubClient->loadEnrollment();
195195
$serverId = $enrollment !== null ? $enrollment->serverId : '';
196196

197+
if ($enrollment !== null && $enrollment->hubBaseUrl !== '') {
198+
$config = $config->withAutoEnable($enrollment->hubBaseUrl);
199+
}
200+
197201
return new RelayConsumer(
198202
$config,
199203
$hubClient,

0 commit comments

Comments
 (0)