Skip to content

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.

feat(domains): add configurable HTTPS redirects for service apps

Andras Bacsai17d9d1a3701d
diff --git a/app/Actions/Service/UpdateServiceApplicationFromApi.php b/app/Actions/Service/UpdateServiceApplicationFromApi.php
index 9d97c47380..123b752c0f 100644
--- a/app/Actions/Service/UpdateServiceApplicationFromApi.php
+++ b/app/Actions/Service/UpdateServiceApplicationFromApi.php
@@ -88,6 +88,10 @@ class UpdateServiceApplicationFromApi
$serviceApplication->is_stripprefix_enabled = filter_var($payload['is_stripprefix_enabled'], FILTER_VALIDATE_BOOLEAN);
}
+ if (array_key_exists('is_force_https_enabled', $payload)) {
+ $serviceApplication->is_force_https_enabled = filter_var($payload['is_force_https_enabled'], FILTER_VALIDATE_BOOLEAN);
+ }
+
if (array_key_exists('is_log_drain_enabled', $payload)) {
$enabled = filter_var($payload['is_log_drain_enabled'], FILTER_VALIDATE_BOOLEAN);
$server = $serviceApplication->service->destination->server;
diff --git a/app/Http/Controllers/Api/ServiceApplicationsController.php b/app/Http/Controllers/Api/ServiceApplicationsController.php
index 414aff0359..e8446467de 100644
--- a/app/Http/Controllers/Api/ServiceApplicationsController.php
+++ b/app/Http/Controllers/Api/ServiceApplicationsController.php
@@ -256,6 +256,7 @@ class ServiceApplicationsController extends Controller
'is_log_drain_enabled' => new OA\Property(property: 'is_log_drain_enabled', type: 'boolean', nullable: true),
'is_gzip_enabled' => new OA\Property(property: 'is_gzip_enabled', type: 'boolean', nullable: true),
'is_stripprefix_enabled' => new OA\Property(property: 'is_stripprefix_enabled', type: 'boolean', nullable: true),
+ 'is_force_https_enabled' => new OA\Property(property: 'is_force_https_enabled', type: 'boolean', nullable: true),
]
)
)
@@ -328,6 +329,7 @@ class ServiceApplicationsController extends Controller
'is_log_drain_enabled',
'is_gzip_enabled',
'is_stripprefix_enabled',
+ 'is_force_https_enabled',
];
$validationRules = [
@@ -341,6 +343,7 @@ class ServiceApplicationsController extends Controller
'is_log_drain_enabled' => 'sometimes|boolean',
'is_gzip_enabled' => 'sometimes|boolean',
'is_stripprefix_enabled' => 'sometimes|boolean',
+ 'is_force_https_enabled' => 'sometimes|boolean',
];
$validator = Validator::make($payload, $validationRules);
diff --git a/app/Livewire/Project/Application/Domains.php b/app/Livewire/Project/Application/Domains.php
index 477abc08e6..45a76a4c33 100644
--- a/app/Livewire/Project/Application/Domains.php
+++ b/app/Livewire/Project/Application/Domains.php
@@ -23,6 +23,8 @@ class Domains extends Component
public string $redirect = 'both';
+ public bool $isForceHttpsEnabled = true;
+
/**
* Per compose-service www/non-www redirect direction.
* Keys are wire-safe (dots encoded) — use serviceRedirectWireKey().
@@ -109,6 +111,7 @@ class Domains extends Component
'newDomain' => ValidationPatterns::applicationDomainRules(),
'editingDomain' => ValidationPatterns::applicationDomainRules(),
'redirect' => 'string|required|in:both,www,non-www',
+ 'isForceHttpsEnabled' => 'boolean',
'serviceRedirects' => 'array',
'serviceRedirects.*' => 'string|in:both,www,non-www',
];
@@ -160,6 +163,18 @@ class Domains extends Component
$this->setRedirect();
}
+ public function updateForceHttps(): void
+ {
+ $this->authorize('update', $this->application);
+ $this->validateOnly('isForceHttpsEnabled');
+
+ $this->application->settings->is_force_https_enabled = $this->isForceHttpsEnabled;
+ $this->application->settings->save();
+ $this->resetDefaultLabels();
+ $this->dispatch('configurationChanged')->to(ConfigurationChecker::class);
+ $this->dispatch('success', 'HTTP to HTTPS redirect updated.');
+ }
+
public function loadDomainState(): void
{
$this->application->refresh();
@@ -168,6 +183,7 @@ class Domains extends Component
$this->isCompose = $this->application->build_pack === 'dockercompose';
$this->labelsAreWritable = $this->application->settings->is_container_label_readonly_enabled === false;
$this->redirect = $this->application->redirect ?? 'both';
+ $this->isForceHttpsEnabled = $this->application->isForceHttpsEnabled();
$settings = instanceSettings();
$this->dnsValidationEnabled = (bool) data_get($settings, 'is_dns_validation_enabled', true);
diff --git a/app/Livewire/Project/Service/Domains.php b/app/Livewire/Project/Service/Domains.php
index ad31560b5a..4690335d86 100644
--- a/app/Livewire/Project/Service/Domains.php
+++ b/app/Livewire/Project/Service/Domains.php
@@ -33,6 +33,9 @@ class Domains extends Component
*/
public array $serviceRedirects = [];
+ /** @var array<int|string, bool> */
+ public array $forceHttpsRedirects = [];
+
/** Service application id when a pending domain conflict belongs to setServiceRedirect. */
public ?int $pendingRedirectServiceApplicationId = null;
@@ -110,6 +113,8 @@ class Domains extends Component
'newServiceApplicationId' => 'nullable|integer',
'serviceRedirects' => 'array',
'serviceRedirects.*' => 'string|in:both,www,non-www',
+ 'forceHttpsRedirects' => 'array',
+ 'forceHttpsRedirects.*' => 'boolean',
];
}
@@ -143,6 +148,22 @@ class Domains extends Component
$this->dispatch('success', 'Search engine indexing updated.');
}
+ public function updateForceHttps(int $serviceApplicationId, bool $enabled): void
+ {
+ $application = $this->service->applications()->findOrFail($serviceApplicationId);
+ $this->authorize('update', $application);
+
+ $this->forceHttpsRedirects[$serviceApplicationId] = $enabled;
+ $this->validateOnly("forceHttpsRedirects.{$serviceApplicationId}");
+
+ $application->is_force_https_enabled = $enabled;
+ $application->save();
+ $this->service->parse();
+ $this->refreshDomains();
+ $this->dispatch('configurationChanged')->to(ConfigurationChecker::class);
+ $this->dispatch('success', 'HTTP to HTTPS redirect updated.');
+ }
+
public function loadDomainState(): void
{
$this->service->loadMissing(['applications', 'server']);
@@ -167,6 +188,10 @@ class Domains extends Component
$this->serverIpConfigured = null;
}
+ $this->forceHttpsRedirects = $this->service->applications
+ ->mapWithKeys(fn (ServiceApplication $app) => [$app->id => $app->isForceHttpsEnabled()])
+ ->all();
+
$this->serviceApps = $this->service->applications
->sortBy(fn (ServiceApplication $app) => strtolower($app->human_name ?: $app->name))
->values()
@@ -518,9 +543,7 @@ class Domains extends Component
public function updatedNewDomain(): void
{
- $this->addDomainDnsFailed = false;
- $this->addDomainDnsMessage = '';
- $this->forceSaveDns = false;
+ $this->resetAddDomainDnsGate();
}
public function updatedNewDomainParts(): void
@@ -529,6 +552,13 @@ class Domains extends Component
$this->resetAddDomainDnsGate();
}
+ public function resetAddDomainDnsGate(): void
+ {
+ $this->addDomainDnsFailed = false;
+ $this->addDomainDnsMessage = '';
+ $this->forceSaveDns = false;
+ }
+
public function updatedEditingDomain(): void
{
$this->editDomainDnsFailed = false;
diff --git a/app/Mcp/Concerns/BuildsResponse.php b/app/Mcp/Concerns/BuildsResponse.php
index d429edb5ff..280e26b9e7 100644
--- a/app/Mcp/Concerns/BuildsResponse.php
+++ b/app/Mcp/Concerns/BuildsResponse.php
@@ -47,6 +47,18 @@ trait BuildsResponse
// app/env secrets
'value', 'real_value', 'http_basic_auth_password',
+ // free-form commands / configurations can embed credentials
+ 'git_full_url',
+ 'install_command', 'build_command', 'start_command',
+ 'health_check_command', 'health_check_response_text',
+ 'custom_docker_run_options', 'pre_deployment_command', 'post_deployment_command',
+ 'docker_compose_custom_start_command', 'docker_compose_custom_build_command',
+ 'custom_nginx_configuration',
+
+ // raw database configuration blobs
+ 'postgres_conf', 'mysql_conf', 'mariadb_conf', 'mongo_conf',
+ 'redis_conf', 'keydb_conf',
+
// database connection strings embed credentials
'internal_db_url', 'external_db_url', 'init_scripts',
@@ -58,6 +70,7 @@ trait BuildsResponse
// bulky / unsafe blobs
'dockerfile', 'docker_compose', 'docker_compose_raw',
+ 'last_saved_proxy_configuration',
'custom_labels', 'environment_variables',
'environment_variables_preview', 'validation_logs',
'server_metadata', 'logs', 'configuration_snapshot',
diff --git a/app/Models/ServiceApplication.php b/app/Models/ServiceApplication.php
index 4afc6c29d2..9763fa894b 100644
--- a/app/Models/ServiceApplication.php
+++ b/app/Models/ServiceApplication.php
@@ -31,6 +31,7 @@ class ServiceApplication extends BaseModel
'is_include_timestamps',
'is_gzip_enabled',
'is_stripprefix_enabled',
+ 'is_force_https_enabled',
'last_online_at',
'is_migrated',
];
@@ -44,11 +45,16 @@ class ServiceApplication extends BaseModel
'domain_dns_statuses',
];
+ protected $attributes = [
+ 'is_force_https_enabled' => true,
+ ];
+
protected function casts(): array
{
return [
'domain_dns_statuses' => 'array',
'noindex_domains' => 'array',
+ 'is_force_https_enabled' => 'boolean',
];
}
@@ -124,6 +130,11 @@ class ServiceApplication extends BaseModel
return data_get($this, 'is_gzip_enabled', true);
}
+ public function isForceHttpsEnabled(): bool
+ {
+ return $this->is_force_https_enabled;
+ }
+
public function type()
{
return 'service';
diff --git a/app/View/Components/Services/Links.php b/app/View/Components/Services/Links.php
index 147b49d686..5b77dc90f3 100644
--- a/app/View/Components/Services/Links.php
+++ b/app/View/Components/Services/Links.php
@@ -12,7 +12,7 @@ class Links extends Component
{
public Collection $links;
- public function __construct(public Service $service, public bool $fullWidth = false)
+ public function __construct(public Service $service, public bool $fullWidth = false, public bool $compact = false)
{
$this->links = collect([]);
$service->applications()->get()->map(function ($application) {
diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php
index d4466d3893..ae29637554 100644
--- a/bootstrap/helpers/docker.php
+++ b/bootstrap/helpers/docker.php
@@ -518,6 +518,10 @@ function fqdnLabelsForCaddy(string $network, string $uuid, Collection $domains,
$path = $url->getPath();
$host_without_www = str($host)->replace('www.', '');
$schema = $url->getScheme();
+ $siteAddress = "{$schema}://{$host}";
+ if ($schema === 'https' && ! $is_force_https_enabled) {
+ $siteAddress = "http://{$host}, https://{$host}";
+ }
$port = $url->getPort();
$handle = 'handle_path';
if (! $is_stripprefix_enabled) {
@@ -529,7 +533,7 @@ function fqdnLabelsForCaddy(string $network, string $uuid, Collection $domains,
if (is_null($port) && $predefinedPort) {
$port = $predefinedPort;
}
- $labels->push("caddy_{$loop}={$schema}://{$host}");
+ $labels->push("caddy_{$loop}={$siteAddress}");
if (isNoindexDomain($domain, $noindex_domains)) {
// Caddy's header directive takes either inline arguments or a block,
// never both, so -Server has to move into the block alongside it.
@@ -549,11 +553,12 @@ function fqdnLabelsForCaddy(string $network, string $uuid, Collection $domains,
if ($is_gzip_enabled) {
$labels->push("caddy_{$loop}.encode=zstd gzip");
}
+ $redirect_schema = $is_force_https_enabled ? $schema : '{scheme}';
if ($redirect_direction === 'www' && ! str($host)->startsWith('www.')) {
- $labels->push("caddy_{$loop}.redir={$schema}://www.{$host}{uri}");
+ $labels->push("caddy_{$loop}.redir={$redirect_schema}://www.{$host}{uri}");
}
if ($redirect_direction === 'non-www' && str($host)->startsWith('www.')) {
- $labels->push("caddy_{$loop}.redir={$schema}://{$host_without_www}{uri}");
+ $labels->push("caddy_{$loop}.redir={$redirect_schema}://{$host_without_www}{uri}");
}
if ($is_http_basic_auth_enabled) {
$labels->push("caddy_{$loop}.basicauth.{$http_basic_auth_username}=\"{$hashedPassword}\"");
@@ -696,8 +701,7 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_
$middlewares->push($middleware_name);
});
if ($middlewares->isNotEmpty()) {
- $middlewares = $middlewares->join(',');
- $labels->push("traefik.http.routers.{$https_label}.middlewares={$middlewares}");
+ $labels->push("traefik.http.routers.{$https_label}.middlewares={$middlewares->join(',')}");
}
} else {
$middlewares = collect([]);
@@ -725,8 +729,7 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_
$middlewares->push($middleware_name);
});
if ($middlewares->isNotEmpty()) {
- $middlewares = $middlewares->join(',');
- $labels->push("traefik.http.routers.{$https_label}.middlewares={$middlewares}");
+ $labels->push("traefik.http.routers.{$https_label}.middlewares={$middlewares->join(',')}");
}
}
$labels->push("traefik.http.routers.{$https_label}.tls=true");
@@ -739,15 +742,17 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_
$labels->push("traefik.http.services.{$http_label}.loadbalancer.server.port=$port");
$labels->push("traefik.http.routers.{$http_label}.service={$http_label}");
}
- $middlewares = collect([]);
- if ($is_noindex) {
- $middlewares->push($noindex_name);
- }
if ($is_force_https_enabled) {
- $middlewares->push('redirect-to-https');
+ $httpMiddlewares = collect([]);
+ if ($is_noindex) {
+ $httpMiddlewares->push($noindex_name);
+ }
+ $httpMiddlewares->push('redirect-to-https');
+ } else {
+ $httpMiddlewares = $middlewares;
}
- if ($middlewares->isNotEmpty()) {
- $labels->push("traefik.http.routers.{$http_label}.middlewares={$middlewares->join(',')}");
+ if ($httpMiddlewares->isNotEmpty()) {
+ $labels->push("traefik.http.routers.{$http_label}.middlewares={$httpMiddlewares->join(',')}");
}
} else {
// Set labels for http
diff --git a/bootstrap/helpers/parsers.php b/bootstrap/helpers/parsers.php
index ddfd455319..7dd1c163c0 100644
--- a/bootstrap/helpers/parsers.php
+++ b/bootstrap/helpers/parsers.php
@@ -1359,9 +1359,6 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int
$redirectDirection = in_array($composeRedirect, ['www', 'non-www', 'both'], true)
? $composeRedirect
: 'both';
- if (! $use_network_mode && (! $shouldGenerateLabelsExactly || $server->proxyType() === ProxyTypes::TRAEFIK->value)) {
- $serviceLabels = addTraefikDockerNetworkLabel($serviceLabels, $baseNetwork->first());
- }
if ($shouldGenerateLabelsExactly) {
switch ($server->proxyType()) {
case ProxyTypes::TRAEFIK->value:
@@ -2636,16 +2633,13 @@ function serviceParser(Service $resource): Collection
$redirectDirection = in_array(data_get($originalResource, 'redirect'), ['www', 'non-www', 'both'], true)
? data_get($originalResource, 'redirect')
: 'both';
- if (! $use_network_mode && (! $shouldGenerateLabelsExactly || $server->proxyType() === ProxyTypes::TRAEFIK->value)) {
- $serviceLabels = addTraefikDockerNetworkLabel($serviceLabels, $baseNetwork->first());
- }
if ($shouldGenerateLabelsExactly) {
switch ($server->proxyType()) {
case ProxyTypes::TRAEFIK->value:
$serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(
uuid: $uuid,
domains: $fqdns,
- is_force_https_enabled: true,
+ is_force_https_enabled: $originalResource->isForceHttpsEnabled(),
serviceLabels: $serviceLabels,
is_gzip_enabled: $originalResource->isGzipEnabled(),
is_stripprefix_enabled: $originalResource->isStripprefixEnabled(),
@@ -2660,7 +2654,7 @@ function serviceParser(Service $resource): Collection
network: $network,
uuid: $uuid,
domains: $fqdns,
- is_force_https_enabled: true,
+ is_force_https_enabled: $originalResource->isForceHttpsEnabled(),
serviceLabels: $serviceLabels,
is_gzip_enabled: $originalResource->isGzipEnabled(),
is_stripprefix_enabled: $originalResource->isStripprefixEnabled(),
@@ -2676,7 +2670,7 @@ function serviceParser(Service $resource): Collection
$serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(
uuid: $uuid,
domains: $fqdns,
- is_force_https_enabled: true,
+ is_force_https_enabled: $originalResource->isForceHttpsEnabled(),
serviceLabels: $serviceLabels,
is_gzip_enabled: $originalResource->isGzipEnabled(),
is_stripprefix_enabled: $originalResource->isStripprefixEnabled(),
@@ -2689,7 +2683,7 @@ function serviceParser(Service $resource): Collection
network: $network,
uuid: $uuid,
domains: $fqdns,
- is_force_https_enabled: true,
+ is_force_https_enabled: $originalResource->isForceHttpsEnabled(),
serviceLabels: $serviceLabels,
is_gzip_enabled: $originalResource->isGzipEnabled(),
is_stripprefix_enabled: $originalResource->isStripprefixEnabled(),
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php
index cf63c4776a..78a1f95e50 100644
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@ -3050,7 +3050,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
$serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(
uuid: $resource->uuid,
domains: $fqdns,
- is_force_https_enabled: true,
+ is_force_https_enabled: $savedService->isForceHttpsEnabled(),
serviceLabels: $serviceLabels,
is_gzip_enabled: $savedService->isGzipEnabled(),
is_stripprefix_enabled: $savedService->isStripprefixEnabled(),
@@ -3065,7 +3065,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
network: $resource->destination->network,
uuid: $resource->uuid,
domains: $fqdns,
- is_force_https_enabled: true,
+ is_force_https_enabled: $savedService->isForceHttpsEnabled(),
serviceLabels: $serviceLabels,
is_gzip_enabled: $savedService->isGzipEnabled(),
is_stripprefix_enabled: $savedService->isStripprefixEnabled(),
@@ -3080,7 +3080,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
$serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(
uuid: $resource->uuid,
domains: $fqdns,
- is_force_https_enabled: true,
+ is_force_https_enabled: $savedService->isForceHttpsEnabled(),
serviceLabels: $serviceLabels,
is_gzip_enabled: $savedService->isGzipEnabled(),
is_stripprefix_enabled: $savedService->isStripprefixEnabled(),
@@ -3093,7 +3093,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
network: $resource->destination->network,
uuid: $resource->uuid,
domains: $fqdns,
- is_force_https_enabled: true,
+ is_force_https_enabled: $savedService->isForceHttpsEnabled(),
serviceLabels: $serviceLabels,
is_gzip_enabled: $savedService->isGzipEnabled(),
is_stripprefix_enabled: $savedService->isStripprefixEnabled(),
diff --git a/database/migrations/2026_08_17_000000_add_is_force_https_enabled_to_service_applications_table.php b/database/migrations/2026_08_17_000000_add_is_force_https_enabled_to_service_applications_table.php
new file mode 100644
index 0000000000..f389ef27d1
--- /dev/null
+++ b/database/migrations/2026_08_17_000000_add_is_force_https_enabled_to_service_applications_table.php
@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ Schema::table('service_applications', function (Blueprint $table) {
+ $table->boolean('is_force_https_enabled')->default(true);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('service_applications', function (Blueprint $table) {
+ $table->dropColumn('is_force_https_enabled');
+ });
+ }
+};
diff --git a/resources/views/auth/two-factor-challenge.blade.php b/resources/views/auth/two-factor-challenge.blade.php
index 4170b188fe..b15afc24de 100644
--- a/resources/views/auth/two-factor-challenge.blade.php
+++ b/resources/views/auth/two-factor-challenge.blade.php
@@ -2,35 +2,13 @@
<x-auth.shell title="Coolify" description="Verify your identity to finish signing in.">
<div class="flex flex-col gap-4" x-data="{
showRecovery: false,
- digits: ['', '', '', '', '', ''],
- code: '',
- focusNext(event) {
- const nextInput = event.target.nextElementSibling;
- if (nextInput?.tagName === 'INPUT') nextInput.focus();
- },
- focusPrevious(event) {
- if (event.key !== 'Backspace' || event.target.value) return;
-
- const previousInput = event.target.previousElementSibling;
- if (previousInput?.tagName === 'INPUT') previousInput.focus();
- },
- updateCode() {
- this.code = this.digits.join('');
+ submitAuthenticatorCode(event) {
+ event.target.value = event.target.value.replace(/\D/g, '').slice(0, 6);
- if (this.code.length === 6) {
+ if (event.target.value.length === 6) {
this.$nextTick(() => this.$refs.challengeForm.requestSubmit());
}
},
- pasteCode(event) {
- event.preventDefault();
-
- const pastedDigits = event.clipboardData.getData('text').replace(/\D/g, '').slice(0, 6).split('');
- const inputs = event.currentTarget.querySelectorAll('input[type=text]');
-
- pastedDigits.forEach((digit, index) => this.digits[index] = digit);
- this.updateCode();
- inputs[Math.min(pastedDigits.length, 6) - 1]?.focus();
- },
}">
@if (session('status'))
<x-auth.alert type="success">{{ session('status') }}</x-auth.alert>
@@ -56,17 +34,11 @@
@csrf
<div x-show="!showRecovery" class="flex flex-col gap-3">
- <input type="hidden" name="code" x-model="code" :disabled="showRecovery">
- <div class="flex justify-center gap-2" aria-label="Two-factor authentication code"
- @paste="pasteCode($event)">
- <template x-for="(digit, index) in digits" :key="index">
- <input type="text" inputmode="numeric" pattern="[0-9]*" maxlength="1"
- x-model="digits[index]" :aria-label="`Digit ${index + 1}`"
- @input="focusNext($event); updateCode()" @keydown="focusPrevious($event)"
- class="h-12 w-11 rounded-md border border-neutral-300 bg-white text-center text-lg font-semibold text-neutral-900 transition-colors focus:border-warning focus:outline-none focus:ring-1 focus:ring-warning dark:border-white/10 dark:bg-coolgray-100 dark:text-white sm:h-14 sm:w-12 sm:text-xl"
- autocomplete="one-time-code" />
- </template>
- </div>
+ <input x-ref="authenticatorCode" type="text" name="code" inputmode="numeric"
+ pattern="[0-9]*" maxlength="6" autocomplete="one-time-code" autofocus
+ aria-label="Two-factor authentication code" :disabled="showRecovery"
+ @input="submitAuthenticatorCode($event)"
+ class="mx-auto h-14 w-64 rounded-md border border-neutral-300 bg-white px-4 text-center text-xl font-semibold tracking-[0.5em] text-neutral-900 transition-colors focus:border-warning focus:outline-none focus:ring-1 focus:ring-warning dark:border-white/10 dark:bg-coolgray-100 dark:text-white" />
<button type="button" class="auth-text-link self-center"
x-on:click="showRecovery = true; $nextTick(() => $refs.recoveryCode.focus())">
Use a recovery code
@@ -77,7 +49,7 @@
<x-forms.input x-ref="recoveryCode" name="recovery_code" autocomplete="one-time-code"
x-bind:disabled="!showRecovery" label="{{ __('input.recovery_code') }}" />
<button type="button" class="auth-text-link self-center"
- x-on:click="showRecovery = false; $nextTick(() => $el.closest('form').querySelector('input[type=text]').focus())">
+ x-on:click="showRecovery = false; $nextTick(() => $refs.authenticatorCode.focus())">
Use an authenticator code
</button>
</div>
diff --git a/resources/views/components/services/links.blade.php b/resources/views/components/services/links.blade.php
index 5d78846288..32de3af618 100644
--- a/resources/views/components/services/links.blade.php
+++ b/resources/views/components/services/links.blade.php
@@ -2,15 +2,22 @@
$linkItemClasses = 'listbox-option justify-start! gap-2.5!';
@endphp
-<div @class(['relative', 'w-full' => $fullWidth]) x-data="{ open: false }"
+<div @class([
+ 'relative' => !$compact,
+ 'static' => $compact,
+ 'w-full' => $fullWidth,
+]) x-data="{ open: false }"
x-effect="$dispatch('resource-actions-toggled', { open })" @keydown.escape.window="open = false">
<button type="button" @click="open = !open" @click.outside="open = false" title="Open service links"
@class([
- 'app-tab shrink-0 gap-1' => !$fullWidth,
+ 'app-tab shrink-0 gap-1' => !$fullWidth && !$compact,
'button w-full justify-between' => $fullWidth,
+ 'inline-flex h-6 shrink-0 items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-100 px-2 text-xs font-medium leading-none text-neutral-700 dark:border-white/[0.12] dark:bg-white/[0.07] dark:text-white' => $compact,
])>
<span class="inline-flex items-center gap-2">
- <x-reicon name="external-link" class="size-3.5 shrink-0 opacity-70" />
+ @unless ($compact)
+ <x-reicon name="external-link" class="size-3.5 shrink-0 opacity-70" />
+ @endunless
Links
</span>
<span class="inline-flex transition-transform" :class="open && 'rotate-180'">
@@ -21,7 +28,8 @@
@class([
'listbox-panel top-full! mt-1! max-h-80! overflow-y-auto!',
'left-0! right-0! w-full! min-w-0! max-w-none!' => $fullWidth,
- 'right-0! left-auto! min-w-60! max-w-96!' => !$fullWidth,
+ 'left-1/2! right-auto! w-[calc(100vw-2rem)]! max-w-md! min-w-0! -translate-x-1/2' => $compact,
+ 'right-0! left-auto! min-w-60! max-w-96!' => !$fullWidth && !$compact,
])>
@forelse ($links as $link)
<a class="{{ $linkItemClasses }}" target="_blank" href="{{ $link }}">
diff --git a/resources/views/livewire/project/application/domains.blade.php b/resources/views/livewire/project/application/domains.blade.php
index 04dd249c7e..a11e6930f1 100644
--- a/resources/views/livewire/project/application/domains.blade.php
+++ b/resources/views/livewire/project/application/domains.blade.php
@@ -8,6 +8,9 @@
$helperText = $isCompose
? 'Manage domains for every service in this Docker Compose application.'
: 'Manage domains for this application.';
+ $hasHttpsDomains = collect($domainRows)->contains(
+ fn ($row) => ! ($row['is_suggested'] ?? false) && str_starts_with(strtolower($row['url']), 'https://')
+ );
@endphp
<div class="flex flex-col gap-4"
@@ -66,6 +69,18 @@
{{ $helperText }}
</p>
+ @if ($hasHttpsDomains && ! $labelsAreWritable)
+ <div class="mt-4 max-w-md">
+ <x-forms.listbox id="isForceHttpsEnabled" label="Redirect HTTP to HTTPS"
+ onChange="updateForceHttps"
+ helper="Disable only when Cloudflare Tunnel or another proxy connects to Coolify over HTTP. Keep enabled when Cloudflare uses Full or Full (Strict) SSL."
+ :options="[
+ ['value' => true, 'label' => 'Enabled'],
+ ['value' => false, 'label' => 'Disabled'],
+ ]" :disabled="! auth()->user()->can('update', $application)" />
+ </div>
+ @endif
+
</x-application.settings-section>
{{-- Toolbar --}}
diff --git a/resources/views/livewire/project/service/domains.blade.php b/resources/views/livewire/project/service/domains.blade.php
index 59f5736012..9399efe7f9 100644
--- a/resources/views/livewire/project/service/domains.blade.php
+++ b/resources/views/livewire/project/service/domains.blade.php
@@ -159,12 +159,28 @@
@php
$app = collect($serviceApps)->firstWhere('id', (int) $appId);
$heading = \Illuminate\Support\Str::headline($app['name'] ?? $rows->first()['service_name'] ?? 'Service');
+ $hasHttpsDomains = $rows->contains(
+ fn ($row) => ! ($row['is_suggested'] ?? false) && str_starts_with(strtolower($row['url']), 'https://')
+ );
@endphp
<section id="service-domain-group-{{ $appId }}" wire:key="service-domain-group-{{ $appId }}"
x-show="matchesDomainSearch(@js($heading.' '.$rows->pluck('url')->implode(' ')))"
class="border-b border-neutral-200 last:border-b-0 dark:border-white/10">
- <div class="flex w-full items-center gap-3 border-b border-neutral-200 bg-neutral-50 px-4 py-3 dark:border-white/10 dark:bg-white/[0.04]">
+ <div class="flex w-full flex-wrap items-center gap-3 border-b border-neutral-200 bg-neutral-50 px-4 py-3 dark:border-white/10 dark:bg-white/[0.04]">
<span class="min-w-0 flex-1 truncate text-sm font-medium text-black dark:text-white">{{ $heading }}</span>
+ @if ($hasHttpsDomains)
+ <div class="w-full sm:w-72">
+ <x-forms.listbox id="forceHttpsRedirects.{{ $appId }}"
+ htmlId="service-force-https-{{ $appId }}"
+ label="Redirect HTTP to HTTPS" onChange="updateForceHttps"
+ :onChangeArgs="[(int) $appId]"
+ helper="Disable only when Cloudflare Tunnel or another proxy connects to Coolify over HTTP. Keep enabled when Cloudflare uses Full or Full (Strict) SSL."
+ :options="[
+ ['value' => true, 'label' => 'Enabled'],
+ ['value' => false, 'label' => 'Disabled'],
+ ]" :disabled="! auth()->user()->can('update', $service)" />
+ </div>
+ @endif
</div>
<div wire:key="service-domain-rows-{{ $appId }}-{{ md5(serialize($rows->all())) }}">
diff --git a/resources/views/livewire/project/service/heading.blade.php b/resources/views/livewire/project/service/heading.blade.php
index fd8f604cd3..113a6c5a3f 100644
--- a/resources/views/livewire/project/service/heading.blade.php
+++ b/resources/views/livewire/project/service/heading.blade.php
@@ -64,7 +64,10 @@
<h1 class="min-w-0 max-w-full truncate text-[24px]! leading-7! font-semibold! tracking-tight! text-black dark:text-fg">
{{ $service->name }}
</h1>
- <x-status-summary :status="$service->status" title="Service status" container-name="Containers" />
+ <div class="relative flex w-full min-w-0 items-center gap-2">
+ <x-status-summary :status="$service->status" title="Service status" container-name="Containers" />
+ <x-services.links :service="$service" compact />
+ </div>
</div>
</div>
@@ -169,9 +172,6 @@
</a>
@endif
- <div class="resource-heading-menus w-full">
- <x-services.links :service="$service" full-width />
- </div>
</div>
@teleport('#resource-action-hud-slot')
diff --git a/resources/views/livewire/project/shared/resource-operations.blade.php b/resources/views/livewire/project/shared/resource-operations.blade.php
index 70ba5acfa8..255336d7de 100644
--- a/resources/views/livewire/project/shared/resource-operations.blade.php
+++ b/resources/views/livewire/project/shared/resource-operations.blade.php
@@ -246,7 +246,7 @@
{{ data_get($resource, 'destination.network') }}.
</p>
<x-forms.button
- @click="$wire.cloneTo(@js($resource->destination->uuid), selectedCloneEnvironment)">
+ @click="$wire.cloneTo(currentDestinationUuid, selectedCloneEnvironment)">
Clone resource
</x-forms.button>
</div>
diff --git a/tests/Feature/ApplicationDomainsTest.php b/tests/Feature/ApplicationDomainsTest.php
index fbe72230d1..50c71fe958 100644
--- a/tests/Feature/ApplicationDomainsTest.php
+++ b/tests/Feature/ApplicationDomainsTest.php
@@ -119,6 +119,27 @@ it('lists existing domains as individual rows', function () {
expect(substr_count($html, 'this.$wire.updateRedirect('))->toBe(2);
});
+it('shows the HTTP redirect control for HTTPS domains and persists changes', function () {
+ $this->application->update(['fqdn' => 'https://app.example.com']);
+
+ Livewire::test(Domains::class, ['application' => $this->application->fresh()])
+ ->assertSet('isForceHttpsEnabled', true)
+ ->assertSee('Redirect HTTP to HTTPS')
+ ->assertSee('Keep enabled when Cloudflare uses Full or Full (Strict) SSL.')
+ ->set('isForceHttpsEnabled', false)
+ ->call('updateForceHttps')
+ ->assertHasNoErrors();
+
+ expect($this->application->settings->fresh()->is_force_https_enabled)->toBeFalse();
+});
+
+it('hides the HTTP redirect control for HTTP-only domains', function () {
+ $this->application->update(['fqdn' => 'http://app.example.com']);
+
+ Livewire::test(Domains::class, ['application' => $this->application->fresh()])
+ ->assertDontSee('Redirect HTTP to HTTPS');
+});
+
it('shows one redirect direction control in each compose service header', function () {
$this->application->update([
'build_pack' => 'dockercompose',
diff --git a/tests/Feature/ApplicationParserDockerComposeDomainsTest.php b/tests/Feature/ApplicationParserDockerComposeDomainsTest.php
index 270927ca18..1b3e61be07 100644
--- a/tests/Feature/ApplicationParserDockerComposeDomainsTest.php
+++ b/tests/Feature/ApplicationParserDockerComposeDomainsTest.php
@@ -399,7 +399,7 @@ YAML;
expect(json_decode($plainApplication->docker_compose_domains, true))->toBeNull();
});
-test('applicationParser selects the Coolify network for Traefik routed compose services', function () {
+test('applicationParser does not force the private resource network for Traefik routed compose services', function () {
$application = Application::factory()->create([
'environment_id' => $this->environment->id,
'destination_id' => $this->destination->id,
@@ -422,7 +422,7 @@ YAML,
$parsedCompose = applicationParser($application);
$labels = collect(data_get($parsedCompose, 'services.frontend.labels'));
- expect($labels->values()->all())->toContain("traefik.docker.network={$application->uuid}");
+ expect($labels->values()->all())->not->toContain("traefik.docker.network={$application->uuid}");
});
test('applicationParser preserves a user-selected Traefik network', function () {
diff --git a/tests/Feature/Auth/TwoFactorChallengeAccessTest.php b/tests/Feature/Auth/TwoFactorChallengeAccessTest.php
index 4f1dee08c5..f0dd97cc31 100644
--- a/tests/Feature/Auth/TwoFactorChallengeAccessTest.php
+++ b/tests/Feature/Auth/TwoFactorChallengeAccessTest.php
@@ -23,6 +23,18 @@ it('allows unauthenticated access to two-factor-challenge page', function () {
expect($response->status())->toBeIn([200, 302]);
});
+it('uses one mobile-friendly field for authenticator code paste and autofill', function () {
+ $challenge = file_get_contents(resource_path('views/auth/two-factor-challenge.blade.php'));
+
+ expect($challenge)
+ ->toContain('name="code"')
+ ->toContain('autocomplete="one-time-code"')
+ ->toContain('inputmode="numeric"')
+ ->toContain('maxlength="6"')
+ ->toContain('@input="submitAuthenticatorCode($event)"')
+ ->not->toContain('x-for="(digit, index) in digits"');
+});
+
it('includes two-factor-challenge in allowed paths for unsubscribed accounts', function () {
$paths = allowedPathsForUnsubscribedAccounts();
diff --git a/tests/Feature/ListboxTriggerTruncationTest.php b/tests/Feature/ListboxTriggerTruncationTest.php
index a64a97dd8a..d5f259a853 100644
--- a/tests/Feature/ListboxTriggerTruncationTest.php
+++ b/tests/Feature/ListboxTriggerTruncationTest.php
@@ -114,7 +114,8 @@ test('listbox forwards dynamic disabled state to its trigger', function () {
->toContain('x-model="selectedCloneProject"')
->toContain('x-model="selectedCloneEnvironment"')
->toContain('$wire.cloneTo(selectedCloneDestination)')
- ->toContain('$wire.cloneTo(@js($resource->destination->uuid), selectedCloneEnvironment)')
+ ->toContain('$wire.cloneTo(currentDestinationUuid, selectedCloneEnvironment)')
+ ->not->toContain('$wire.cloneTo(@js(')
->toContain('x-bind:disabled="!selectedMoveProject || availableEnvironments.length === 0"');
});
diff --git a/tests/Feature/Mcp/McpEndpointTest.php b/tests/Feature/Mcp/McpEndpointTest.php
index 240f5b2e14..01ba0ecf16 100644
--- a/tests/Feature/Mcp/McpEndpointTest.php
+++ b/tests/Feature/Mcp/McpEndpointTest.php
@@ -216,6 +216,13 @@ test('get_infrastructure_overview returns counts', function () {
test('get_server scrubs sensitive nested data and exposes connection_timeout', function () {
$server = Server::factory()->create(['team_id' => $this->team->id]);
+ $server->proxy->set('last_saved_proxy_configuration', <<<'YAML'
+services:
+ traefik:
+ environment:
+ CF_DNS_API_TOKEN: plaintext-cloudflare-token
+YAML);
+ $server->saveQuietly();
// creating hook auto-generates a sentinel_token; bump connection_timeout
// via saveQuietly to avoid triggering restartSentinel.
$server->settings->forceFill(['connection_timeout' => 42])->saveQuietly();
@@ -229,6 +236,9 @@ test('get_server scrubs sensitive nested data and exposes connection_timeout', f
$raw = json_encode($body);
expect($raw)->not->toContain('sentinel_token');
+ expect($raw)->not->toContain('last_saved_proxy_configuration');
+ expect($raw)->not->toContain('CF_DNS_API_TOKEN');
+ expect($raw)->not->toContain('plaintext-cloudflare-token');
expect($raw)->not->toContain('"team_id"');
expect($raw)->not->toContain('"private_key_id"');
expect($body['data']['connection_timeout'])->toBe(42);
diff --git a/tests/Feature/Mcp/McpReadToolsTest.php b/tests/Feature/Mcp/McpReadToolsTest.php
index c3433bf455..6e146e7190 100644
--- a/tests/Feature/Mcp/McpReadToolsTest.php
+++ b/tests/Feature/Mcp/McpReadToolsTest.php
@@ -590,6 +590,51 @@ test('list_env_keys never returns values and is team scoped', function () {
expect($denied->json('result.isError'))->toBeTrue();
});
+test('get_application omits free-form configuration that can contain secrets', function () {
+ $this->application->update([
+ 'git_full_url' => 'https://oauth2:[email protected]/repository.git',
+ 'build_command' => 'API_TOKEN=application-secret npm run build',
+ 'custom_docker_run_options' => '--env API_TOKEN=application-secret',
+ 'custom_nginx_configuration' => base64_encode('proxy_set_header Authorization "Bearer application-secret";'),
+ ]);
+
+ $response = mcpReadCall('get_application', ['uuid' => $this->application->uuid]);
+ $response->assertOk();
+
+ $body = mcpReadJson($response);
+ $raw = json_encode($body);
+
+ expect($body['data']['uuid'])->toBe($this->application->uuid)
+ ->and($raw)->not->toContain('application-secret')
+ ->and($raw)->not->toContain('git_full_url')
+ ->and($raw)->not->toContain('build_command')
+ ->and($raw)->not->toContain('custom_docker_run_options')
+ ->and($raw)->not->toContain('custom_nginx_configuration');
+});
+
+test('get_database omits configuration blobs that can contain secrets', function () {
+ $database = StandalonePostgresql::create([
+ 'name' => 'Secret-bearing config',
+ 'postgres_password' => 'database-password',
+ 'postgres_conf' => "primary_conninfo = 'password=database-config-secret'",
+ 'custom_docker_run_options' => '--env API_TOKEN=database-config-secret',
+ 'environment_id' => $this->environment->id,
+ 'destination_id' => $this->destination->id,
+ 'destination_type' => $this->destination->getMorphClass(),
+ ]);
+
+ $response = mcpReadCall('get_database', ['uuid' => $database->uuid]);
+ $response->assertOk();
+
+ $body = mcpReadJson($response);
+ $raw = json_encode($body);
+
+ expect($body['data']['uuid'])->toBe($database->uuid)
+ ->and($raw)->not->toContain('database-config-secret')
+ ->and($raw)->not->toContain('postgres_conf')
+ ->and($raw)->not->toContain('custom_docker_run_options');
+});
+
test('list_destinations and get_destination are team scoped', function () {
$response = mcpReadCall('list_destinations');
$response->assertOk();
diff --git a/tests/Feature/ModelFillableCreationTest.php b/tests/Feature/ModelFillableCreationTest.php
index 50b6e02a98..46d9c36daa 100644
--- a/tests/Feature/ModelFillableCreationTest.php
+++ b/tests/Feature/ModelFillableCreationTest.php
@@ -463,6 +463,7 @@ it('creates ServiceApplication with all fillable attributes', function () {
'is_include_timestamps' => true,
'is_gzip_enabled' => true,
'is_stripprefix_enabled' => true,
+ 'is_force_https_enabled' => false,
'last_online_at' => now()->toISOString(),
'is_migrated' => false,
]);
@@ -473,6 +474,26 @@ it('creates ServiceApplication with all fillable attributes', function () {
expect($svcApp->human_name)->toBe('Web Server');
expect($svcApp->image)->toBe('nginx:latest');
expect($svcApp->is_log_drain_enabled)->toBeTrue();
+ expect($svcApp->is_force_https_enabled)->toBeFalse();
+ expect($svcApp->isForceHttpsEnabled())->toBeFalse();
+});
+
+it('enables HTTPS redirects for service applications by default', function () {
+ $service = Service::create([
+ 'docker_compose_raw' => 'services: {}',
+ 'environment_id' => $this->environment->id,
+ 'server_id' => $this->server->id,
+ 'destination_id' => $this->destination->id,
+ 'destination_type' => $this->destination->getMorphClass(),
+ ]);
+
+ $serviceApplication = ServiceApplication::create([
+ 'service_id' => $service->id,
+ 'name' => 'web-default-redirect',
+ ]);
+
+ expect($serviceApplication->is_force_https_enabled)->toBeTrue();
+ expect($serviceApplication->isForceHttpsEnabled())->toBeTrue();
});
it('creates ServiceDatabase with all fillable attributes', function () {
diff --git a/tests/Feature/ResourceHeadingUnifiedNavbarTest.php b/tests/Feature/ResourceHeadingUnifiedNavbarTest.php
index 81e596ebf1..bb9e888982 100644
--- a/tests/Feature/ResourceHeadingUnifiedNavbarTest.php
+++ b/tests/Feature/ResourceHeadingUnifiedNavbarTest.php
@@ -635,20 +635,31 @@ it('shows application Links as a compact badge beside the mobile status', functi
->toContain('<x-reicon name="chevron-down"');
});
-it('keeps service Links full width on mobile headings', function () {
+it('shows service Links as a compact badge beside the mobile status', function () {
$service = file_get_contents(resource_path('views/livewire/project/service/heading.blade.php'));
- $mobileServiceSection = str($service)->between('class="w-full md:hidden"', 'class="hidden w-full items-center md:flex')->toString();
+ $serviceLinks = file_get_contents(resource_path('views/components/services/links.blade.php'));
+ $serviceLinksComponent = file_get_contents(app_path('View/Components/Services/Links.php'));
+ $mobileServiceTitle = str($service)->between('class="mb-3 w-full xl:hidden"', '<div class="w-full xl:hidden">')->toString();
+ $mobileServiceActions = str($service)->between('<div class="w-full xl:hidden">', '@teleport')->toString();
- expect($mobileServiceSection)
+ expect($mobileServiceTitle)
+ ->toContain('<x-status-summary')
->toContain('<x-services.links')
- ->toContain('full-width')
- ->toContain('resource-heading-menus')
- ->not->toContain('<x-resource-heading-tabs');
+ ->toContain('relative flex w-full min-w-0 items-center gap-2')
+ ->toContain('compact')
+ ->not->toContain('full-width');
+
+ expect($mobileServiceActions)
+ ->not->toContain('<x-services.links');
+
+ expect($serviceLinksComponent)
+ ->toContain('public bool $compact = false');
- $serviceLinks = file_get_contents(resource_path('views/components/services/links.blade.php'));
expect($serviceLinks)
- ->toContain("'button w-full justify-between' => \$fullWidth")
- ->toContain("'left-0! right-0! w-full! min-w-0! max-w-none!' => \$fullWidth")
+ ->toContain("'static' => \$compact")
+ ->toContain("'inline-flex h-6 shrink-0 items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-100 px-2 text-xs font-medium leading-none text-neutral-700 dark:border-white/[0.12] dark:bg-white/[0.07] dark:text-white' => \$compact")
+ ->toContain('@unless ($compact)')
+ ->toContain("'left-1/2! right-auto! w-[calc(100vw-2rem)]! max-w-md! min-w-0! -translate-x-1/2' => \$compact")
->toContain('<x-reicon name="chevron-down"')
->toContain('No links available');
diff --git a/tests/Feature/ServiceApplicationsApiTest.php b/tests/Feature/ServiceApplicationsApiTest.php
index d65967bd80..c8dd33a46b 100644
--- a/tests/Feature/ServiceApplicationsApiTest.php
+++ b/tests/Feature/ServiceApplicationsApiTest.php
@@ -199,6 +199,20 @@ describe('PATCH /api/v1/services/{uuid}/applications/{app_uuid}', function () {
expect($ctx->serviceApplication->human_name)->toBe('Web UI');
});
+ test('updates the HTTP to HTTPS redirect setting', function () {
+ config(['app.maintenance.driver' => 'file']);
+ $ctx = createServiceWithApplicationForApiTest($this);
+
+ $response = $this->withHeaders([
+ 'Authorization' => 'Bearer '.$this->bearerToken,
+ ])->patchJson("/api/v1/services/{$ctx->service->uuid}/applications/{$ctx->serviceApplication->uuid}", [
+ 'is_force_https_enabled' => false,
+ ]);
+
+ $response->assertSuccessful();
+ expect($ctx->serviceApplication->fresh()->is_force_https_enabled)->toBeFalse();
+ });
+
test('returns 422 for invalid url scheme', function () {
$ctx = createServiceWithApplicationForApiTest($this);
diff --git a/tests/Feature/ServiceDomainsTest.php b/tests/Feature/ServiceDomainsTest.php
index 36f602856f..62ea41d96d 100644
--- a/tests/Feature/ServiceDomainsTest.php
+++ b/tests/Feature/ServiceDomainsTest.php
@@ -125,6 +125,24 @@ it('groups configured domains and shows redirect settings in the table', functio
->and(substr_count($html, "id=\"service-domain-group-{$this->apiApp->id}\""))->toBe(1);
});
+it('shows and persists the HTTP redirect control for HTTPS service applications', function () {
+ Livewire::test(Domains::class, ['service' => $this->service->fresh(['applications', 'server'])])
+ ->assertSee('Redirect HTTP to HTTPS')
+ ->assertSee('Keep enabled when Cloudflare uses Full or Full (Strict) SSL.')
+ ->call('updateForceHttps', $this->apiApp->id, false)
+ ->assertHasNoErrors();
+
+ expect($this->apiApp->fresh()->is_force_https_enabled)->toBeFalse();
+ expect($this->service->fresh()->docker_compose)->not->toContain('middlewares=redirect-to-https');
+});
+
+it('hides the HTTP redirect control for HTTP-only service applications', function () {
+ $this->apiApp->update(['fqdn' => 'http://api.example.com']);
+
+ Livewire::test(Domains::class, ['service' => $this->service->fresh(['applications', 'server'])])
+ ->assertDontSee('Redirect HTTP to HTTPS');
+});
+
it('shows one redirect control for each www and non-www pair', function () {
$this->apiApp->update([
'fqdn' => 'https://api.example.com,https://www.api.example.com,https://admin.example.com,https://www.admin.example.com',
@@ -146,6 +164,18 @@ it('uses segmented fields when adding and editing service domains', function ()
->not->toContain('placeholder="https://app.example.com"');
});
+it('resets the add domain dns gate when segmented domain fields change', function () {
+ Livewire::test(Domains::class, ['service' => $this->service->fresh(['applications', 'server'])])
+ ->set('addDomainDnsFailed', true)
+ ->set('addDomainDnsMessage', 'DNS validation failed.')
+ ->set('forceSaveDns', true)
+ ->set('newDomainParts.host', 'web.example.com')
+ ->assertSet('newDomainPartsChanged', true)
+ ->assertSet('addDomainDnsFailed', false)
+ ->assertSet('addDomainDnsMessage', '')
+ ->assertSet('forceSaveDns', false);
+});
+
it('shows dns entries control next to Add', function () {
Livewire::test(Domains::class, ['service' => $this->service->fresh(['applications', 'server'])])
->assertSuccessful()
diff --git a/tests/Feature/TraefikServiceDockerNetworkLabelTest.php b/tests/Feature/TraefikServiceDockerNetworkLabelTest.php
index 4cf4ebc568..f1d7087a29 100644
--- a/tests/Feature/TraefikServiceDockerNetworkLabelTest.php
+++ b/tests/Feature/TraefikServiceDockerNetworkLabelTest.php
@@ -12,7 +12,7 @@ use Illuminate\Support\Facades\Bus;
uses(RefreshDatabase::class);
-it('selects the Coolify service network for Traefik routed compose services', function () {
+it('does not force the private service network for Traefik routed compose services', function () {
Bus::fake();
$team = Team::factory()->create();
@@ -45,5 +45,5 @@ YAML,
$parsedCompose = serviceParser($service);
$labels = collect(data_get($parsedCompose, 'services.app.labels'));
- expect($labels->values()->all())->toContain("traefik.docker.network={$service->uuid}");
+ expect($labels->values()->all())->not->toContain("traefik.docker.network={$service->uuid}");
});
diff --git a/tests/Unit/FqdnLabelsNoindexTest.php b/tests/Unit/FqdnLabelsNoindexTest.php
index 48f2f49126..332d548989 100644
--- a/tests/Unit/FqdnLabelsNoindexTest.php
+++ b/tests/Unit/FqdnLabelsNoindexTest.php
@@ -17,13 +17,14 @@ function traefikLabels(array $domains, ?array $noindex = null, bool $forceHttps
)->values()->all();
}
-function caddyLabels(array $domains, ?array $noindex = null): array
+function caddyLabels(array $domains, ?array $noindex = null, bool $forceHttps = false): array
{
return fqdnLabelsForCaddy(
network: 'testnetwork',
uuid: 'testuuid',
domains: collect($domains),
onlyPort: 3000,
+ is_force_https_enabled: $forceHttps,
noindex_domains: $noindex === null ? null : collect($noindex),
)->values()->all();
}
@@ -43,6 +44,33 @@ function middlewaresOf(array $labels, string $router): array
}
describe('Traefik noindex middleware', function () {
+ test('the HTTP router inherits the HTTPS middleware chain when redirects are disabled', function () {
+ $labels = fqdnLabelsForTraefik(
+ uuid: 'testuuid',
+ domains: collect(['https://example.com/api']),
+ is_force_https_enabled: false,
+ onlyPort: 3000,
+ serviceLabels: collect(['coolify.traefik.middlewares=rate-limit']),
+ redirect_direction: 'www',
+ is_http_basic_auth_enabled: true,
+ http_basic_auth_username: 'user',
+ http_basic_auth_password: 'secret',
+ noindex_domains: collect(['https://example.com/api']),
+ )->values()->all();
+
+ expect(middlewaresOf($labels, 'http-0-testuuid'))
+ ->toBe(middlewaresOf($labels, 'https-0-testuuid'))
+ ->toContain(
+ 'https-0-testuuid-stripprefix',
+ 'gzip',
+ '0-testuuid-to-www',
+ 'http-basic-auth-testuuid',
+ '0-testuuid-noindex',
+ 'rate-limit',
+ )
+ ->not->toContain('redirect-to-https');
+ });
+
test('only the flagged domain gets the header', function () {
$labels = traefikLabels(
domains: ['https://prod.example.com', 'https://staging.example.com'],
@@ -138,6 +166,44 @@ describe('Traefik noindex middleware', function () {
});
describe('Caddy noindex header', function () {
+ test('serves an HTTPS public domain over HTTP and HTTPS when the HTTPS redirect is disabled', function () {
+ expect(caddyLabels(['https://example.com'], forceHttps: false))
+ ->toContain('caddy_0=http://example.com, https://example.com');
+ });
+
+ test('serves an HTTPS public domain over HTTPS when the HTTPS redirect is enabled', function () {
+ expect(caddyLabels(['https://example.com'], forceHttps: true))
+ ->toContain('caddy_0=https://example.com');
+ });
+
+ test('canonical redirects preserve the request scheme when the HTTPS redirect is disabled', function (string $domain, string $redirectDirection, string $expectedRedirect, string $httpsRedirect) {
+ $labels = fqdnLabelsForCaddy(
+ network: 'testnetwork',
+ uuid: 'testuuid',
+ domains: collect([$domain]),
+ is_force_https_enabled: false,
+ onlyPort: 3000,
+ redirect_direction: $redirectDirection,
+ );
+
+ expect($labels)
+ ->toContain($expectedRedirect)
+ ->not->toContain($httpsRedirect);
+ })->with([
+ 'www redirect' => [
+ 'https://example.com',
+ 'www',
+ 'caddy_0.redir={scheme}://www.example.com{uri}',
+ 'caddy_0.redir=https://www.example.com{uri}',
+ ],
+ 'non-www redirect' => [
+ 'https://www.example.com',
+ 'non-www',
+ 'caddy_0.redir={scheme}://example.com{uri}',
+ 'caddy_0.redir=https://example.com{uri}',
+ ],
+ ]);
+
test('the flagged domain uses the header block, the other keeps the inline form', function () {
$labels = caddyLabels(
domains: ['https://prod.example.com', 'https://staging.example.com'],
diff --git a/tests/Unit/ServerTransfer/ServerTransferExporterImporterTest.php b/tests/Unit/ServerTransfer/ServerTransferExporterImporterTest.php
index 28675903ba..5f940108c3 100644
--- a/tests/Unit/ServerTransfer/ServerTransferExporterImporterTest.php
+++ b/tests/Unit/ServerTransfer/ServerTransferExporterImporterTest.php
@@ -509,6 +509,7 @@ test('service nested apps dbs volumes backups and db file storages round-trip',
'is_log_drain_enabled' => true,
'is_gzip_enabled' => false,
'is_stripprefix_enabled' => false,
+ 'is_force_https_enabled' => false,
'status' => 'running:healthy',
]);
$serviceApp->uuid = 'svc-app-whoami';
@@ -722,6 +723,7 @@ test('service nested apps dbs volumes backups and db file storages round-trip',
->and($importedSvcApp->exposes)->toBe('80')
->and((bool) $importedSvcApp->is_gzip_enabled)->toBeFalse()
->and((bool) $importedSvcApp->is_stripprefix_enabled)->toBeFalse()
+ ->and((bool) $importedSvcApp->is_force_https_enabled)->toBeFalse()
->and($importedSvcApp->environment_variables()->where('key', 'WHOAMI_NAME')->first()?->value)->toBe('nested-secret')
->and($importedSvcApp->persistentStorages)->toHaveCount(1)
->and($importedSvcApp->fileStorages)->toHaveCount(1)