An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(proxy): prevent automatic Traefik self-exposure
Andras Bacsaib8f630be6b53
diff --git a/bootstrap/helpers/proxy.php b/bootstrap/helpers/proxy.phpindex cc214eb81c..4484701785 100644--- a/bootstrap/helpers/proxy.php+++ b/bootstrap/helpers/proxy.php@@ -359,10 +359,7 @@ function generateDefaultProxyConfiguration(Server $server, array $custom_command});if ($proxy_type === ProxyTypes::TRAEFIK->value) {$labels = [- 'traefik.enable=true',- 'traefik.http.routers.traefik.entrypoints=http',- 'traefik.http.routers.traefik.service=api@internal',- 'traefik.http.services.traefik.loadbalancer.server.port=8080',+ 'traefik.enable=false','coolify.managed=true','coolify.proxy=true',];diff --git a/tests/Feature/TrafficAnalytics/TraefikLogrotateSidecarTest.php b/tests/Feature/TrafficAnalytics/TraefikLogrotateSidecarTest.phpindex 0556fc2472..258dd91a69 100644--- a/tests/Feature/TrafficAnalytics/TraefikLogrotateSidecarTest.php+++ b/tests/Feature/TrafficAnalytics/TraefikLogrotateSidecarTest.php@@ -31,6 +31,55 @@ it('uses the latest stable traefik branch for new proxy configurations', functioexpect($config['services']['traefik']['image'])->toBe('traefik:v3.7');});+it('does not expose the proxy container through its own docker provider', function () {+ $server = Server::factory()->create(['team_id' => $this->team->id, 'private_key_id' => $this->privateKey->id]);+ $server->proxy->set('type', 'TRAEFIK');+ $server->save();++ $config = Yaml::parse(generateDefaultProxyConfiguration($server->fresh()));+ $labels = $config['services']['traefik']['labels'];++ expect($labels)->toContain('traefik.enable=false')+ ->not->toContain('traefik.enable=true')+ ->and(collect($labels)->contains(fn (string $label): bool => str_starts_with($label, 'traefik.http.routers.traefik.')))->toBeFalse();+});++it('preserves intentional self-router labels when updating an existing proxy configuration', function () {+ $server = Server::factory()->create(['team_id' => $this->team->id, 'private_key_id' => $this->privateKey->id]);+ $server->proxy->set('type', 'TRAEFIK');+ $server->save();++ $configuration = applyTrafficAnalyticsToProxyConfiguration($server->fresh(), <<<'YAML'+services:+ traefik:+ command: []+ labels:+ - traefik.enable=true+ - traefik.http.routers.traefik.entrypoints=http+ - traefik.http.routers.traefik.service=api@internal+ - traefik.http.services.traefik.loadbalancer.server.port=8080+ - coolify.managed=true+ deploy:+ labels:+ - traefik.enable=true+ - traefik.http.routers.traefik.entrypoints=http+ - traefik.http.routers.traefik.service=api@internal+ - traefik.http.services.traefik.loadbalancer.server.port=8080+ - coolify.proxy=true+YAML);+ $traefik = Yaml::parse($configuration)['services']['traefik'];++ expect($traefik['labels'])->toContain(+ 'traefik.enable=true',+ 'traefik.http.routers.traefik.service=api@internal',+ 'coolify.managed=true',+ )->and($traefik['deploy']['labels'])->toContain(+ 'traefik.enable=true',+ 'traefik.http.routers.traefik.service=api@internal',+ 'coolify.proxy=true',+ );+});+it('does not add a traefik-logrotate sidecar when traffic analytics is disabled', function () {$server = Server::factory()->create(['team_id' => $this->team->id, 'private_key_id' => $this->privateKey->id]);$server->proxy->set('type', 'TRAEFIK');