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: proxy logs on the ui

Andras Bacsai5541c135df73
diff --git a/app/Http/Livewire/Server/Proxy/Logs.php b/app/Http/Livewire/Server/Proxy/Logs.php
new file mode 100644
index 0000000000..cb8c245a6c
--- /dev/null
+++ b/app/Http/Livewire/Server/Proxy/Logs.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Http\Livewire\Server\Proxy;
+
+use App\Models\Server;
+use Livewire\Component;
+
+class Logs extends Component
+{
+ public ?Server $server = null;
+ public $parameters = [];
+ public function mount()
+ {
+ $this->parameters = get_route_parameters();
+ try {
+ $this->server = Server::ownedByCurrentTeam(['name', 'proxy'])->whereUuid(request()->server_uuid)->first();
+ if (is_null($this->server)) {
+ return redirect()->route('server.all');
+ }
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
+ }
+ }
+ public function render()
+ {
+ return view('livewire.server.proxy.logs');
+ }
+}
diff --git a/app/Http/Livewire/Server/Proxy/Show.php b/app/Http/Livewire/Server/Proxy/Show.php
index daadf0edea..26ea54e491 100644
--- a/app/Http/Livewire/Server/Proxy/Show.php
+++ b/app/Http/Livewire/Server/Proxy/Show.php
@@ -9,6 +9,11 @@ class Show extends Component
{
public ?Server $server = null;
public $parameters = [];
+ protected $listeners = ['proxyStatusUpdated'];
+ public function proxyStatusUpdated()
+ {
+ $this->server->refresh();
+ }
public function mount()
{
$this->parameters = get_route_parameters();
diff --git a/app/View/Components/Server/Sidebar.php b/app/View/Components/Server/Sidebar.php
new file mode 100644
index 0000000000..f968b6d0cf
--- /dev/null
+++ b/app/View/Components/Server/Sidebar.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace App\View\Components\Server;
+
+use App\Models\Server;
+use Closure;
+use Illuminate\Contracts\View\View;
+use Illuminate\View\Component;
+
+class Sidebar extends Component
+{
+ /**
+ * Create a new component instance.
+ */
+ public function __construct(public Server $server, public $parameters)
+ {
+ //
+ }
+
+ /**
+ * Get the view / contents that represent the component.
+ */
+ public function render(): View|Closure|string
+ {
+ return view('components.server.sidebar');
+ }
+}
diff --git a/resources/views/components/server/sidebar.blade.php b/resources/views/components/server/sidebar.blade.php
new file mode 100644
index 0000000000..9aa50bb211
--- /dev/null
+++ b/resources/views/components/server/sidebar.blade.php
@@ -0,0 +1,20 @@
+<div>
+ @if ($server->isFunctional())
+ <div class="flex h-full pr-4">
+ <div class="flex flex-col gap-4 min-w-fit">
+ <a class="{{ request()->routeIs('server.proxy') ? 'text-white' : '' }}"
+ href="{{ route('server.proxy', $parameters) }}">
+ <button>Configuration</button>
+ </a>
+ @if (data_get($server, 'proxy.type') !== 'NONE')
+ <a class="{{ request()->routeIs('server.proxy.logs') ? 'text-white' : '' }}"
+ href="{{ route('server.proxy.logs', $parameters) }}">
+ <button>Logs</button>
+ </a>
+ @endif
+ </div>
+ </div>
+ @else
+ <div>Server is not validated. Validate first.</div>
+ @endif
+</div>
diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.php
index f0bf008743..3c35488e24 100644
--- a/resources/views/livewire/server/proxy.blade.php
+++ b/resources/views/livewire/server/proxy.blade.php
@@ -1,75 +1,71 @@
<div>
- @if ($server->isFunctional())
- @if (data_get($server, 'proxy.type'))
- <div x-init="$wire.loadProxyConfiguration">
- @if ($selectedProxy === 'TRAEFIK_V2')
- <form wire:submit.prevent='submit'>
- <div class="flex items-center gap-2">
- <h2>Proxy</h2>
- <x-forms.button type="submit">Save</x-forms.button>
- @if ($server->proxy->status === 'exited')
- <x-forms.button wire:click.prevent="change_proxy">Switch Proxy</x-forms.button>
- @endif
- </div>
- <div class="pt-3 pb-4 ">Traefik v2</div>
- @if (
- $server->proxy->last_applied_settings &&
- $server->proxy->last_saved_settings !== $server->proxy->last_applied_settings)
- <div class="text-red-500 ">Configuration out of sync. Restart the proxy to apply the new
- configurations.
- </div>
+ @if (data_get($server, 'proxy.type'))
+ <div x-init="$wire.loadProxyConfiguration">
+ @if ($selectedProxy === 'TRAEFIK_V2')
+ <form wire:submit.prevent='submit'>
+ <div class="flex items-center gap-2">
+ <h2>Configuration</h2>
+ <x-forms.button type="submit">Save</x-forms.button>
+ @if ($server->proxy->status === 'exited')
+ <x-forms.button wire:click.prevent="change_proxy">Switch Proxy</x-forms.button>
@endif
- <x-forms.input placeholder="https://app.coolify.io" id="redirect_url" label="Default Redirect 404"
- helper="All urls that has no service available will be redirected to this domain." />
- <div wire:loading wire:target="loadProxyConfiguration" class="pt-4">
- <x-loading text="Loading proxy configuration..." />
- </div>
- <div wire:loading.remove wire:target="loadProxyConfiguration">
- @if ($proxy_settings)
- <div class="flex flex-col gap-2 pt-2">
- <x-forms.textarea label="Configuration file: traefik.conf" name="proxy_settings"
- wire:model.defer="proxy_settings" rows="30" />
- <x-forms.button wire:click.prevent="reset_proxy_configuration">
- Reset configuration to default
- </x-forms.button>
- </div>
- @endif
+ </div>
+ <div class="pt-3 pb-4 ">Traefik v2</div>
+ @if (
+ $server->proxy->last_applied_settings &&
+ $server->proxy->last_saved_settings !== $server->proxy->last_applied_settings)
+ <div class="text-red-500 ">Configuration out of sync. Restart the proxy to apply the new
+ configurations.
</div>
- </form>
- @elseif($selectedProxy === 'NONE')
- <div class="flex items-center gap-2">
- <h2>Proxy</h2>
- <x-forms.button wire:click.prevent="change_proxy">Switch Proxy</x-forms.button>
+ @endif
+ <x-forms.input placeholder="https://app.coolify.io" id="redirect_url" label="Default Redirect 404"
+ helper="All urls that has no service available will be redirected to this domain." />
+ <div wire:loading wire:target="loadProxyConfiguration" class="pt-4">
+ <x-loading text="Loading proxy configuration..." />
</div>
- <div class="pt-3 pb-4">None</div>
- @else
- <div class="flex items-center gap-2">
- <h2>Proxy</h2>
- <x-forms.button wire:click.prevent="change_proxy">Switch Proxy</x-forms.button>
+ <div wire:loading.remove wire:target="loadProxyConfiguration">
+ @if ($proxy_settings)
+ <div class="flex flex-col gap-2 pt-2">
+ <x-forms.textarea label="Configuration file: traefik.conf" name="proxy_settings"
+ wire:model.defer="proxy_settings" rows="30" />
+ <x-forms.button wire:click.prevent="reset_proxy_configuration">
+ Reset configuration to default
+ </x-forms.button>
+ </div>
+ @endif
</div>
- @endif
+ </form>
+ @elseif($selectedProxy === 'NONE')
+ <div class="flex items-center gap-2">
+ <h2>Configuration</h2>
+ <x-forms.button wire:click.prevent="change_proxy">Switch Proxy</x-forms.button>
+ </div>
+ <div class="pt-3 pb-4">Custom (None) Proxy Selected</div>
@else
- <div>
- <h2>Proxy</h2>
- <div class="subtitle">Select a proxy you would like to use on this server.</div>
- <div class="grid gap-4">
- <x-forms.button class="box" wire:click="select_proxy('NONE')">
- Custom (None)
- </x-forms.button>
- <x-forms.button class="box" wire:click="select_proxy('TRAEFIK_V2')">
- Traefik
- v2
- </x-forms.button>
- <x-forms.button disabled class="box">
- Nginx
- </x-forms.button>
- <x-forms.button disabled class="box">
- Caddy
- </x-forms.button>
- </div>
+ <div class="flex items-center gap-2">
+ <h2>Configuration</h2>
+ <x-forms.button wire:click.prevent="change_proxy">Switch Proxy</x-forms.button>
+ </div>
+ @endif
+ @else
+ <div>
+ <h2>Configuration</h2>
+ <div class="subtitle">Select a proxy you would like to use on this server.</div>
+ <div class="grid gap-4">
+ <x-forms.button class="box" wire:click="select_proxy('NONE')">
+ Custom (None)
+ </x-forms.button>
+ <x-forms.button class="box" wire:click="select_proxy('TRAEFIK_V2')">
+ Traefik
+ v2
+ </x-forms.button>
+ <x-forms.button disabled class="box">
+ Nginx
+ </x-forms.button>
+ <x-forms.button disabled class="box">
+ Caddy
+ </x-forms.button>
</div>
- @endif
- @else
- <div>Server is not validated. Validate first.</div>
+ </div>
@endif
</div>
diff --git a/resources/views/livewire/server/proxy/logs.blade.php b/resources/views/livewire/server/proxy/logs.blade.php
new file mode 100644
index 0000000000..58e7184245
--- /dev/null
+++ b/resources/views/livewire/server/proxy/logs.blade.php
@@ -0,0 +1,9 @@
+<div>
+ <x-server.navbar :server="$server" :parameters="$parameters" />
+ <div class="flex gap-2">
+ <x-server.sidebar :server="$server" :parameters="$parameters" />
+ <div class="w-full">
+ <livewire:project.shared.get-logs :server="$server" container="coolify-proxy" />
+ </div>
+ </div>
+</div>
diff --git a/resources/views/livewire/server/proxy/show.blade.php b/resources/views/livewire/server/proxy/show.blade.php
index 6a5018d0b9..33b30448ef 100644
--- a/resources/views/livewire/server/proxy/show.blade.php
+++ b/resources/views/livewire/server/proxy/show.blade.php
@@ -1,4 +1,9 @@
<div>
<x-server.navbar :server="$server" :parameters="$parameters" />
- <livewire:server.proxy :server="$server" />
+ <div class="flex gap-2">
+ <x-server.sidebar :server="$server" :parameters="$parameters" />
+ <div class="w-full">
+ <livewire:server.proxy :server="$server" />
+ </div>
+ </div>
</div>
diff --git a/routes/web.php b/routes/web.php
index 7be6c8ac88..1a9d5851c3 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -5,7 +5,6 @@ use App\Http\Controllers\Controller;
use App\Http\Controllers\DatabaseController;
use App\Http\Controllers\MagicController;
use App\Http\Controllers\ProjectController;
-use App\Http\Controllers\ServerController;
use App\Http\Livewire\Boarding\Index as BoardingIndex;
use App\Http\Livewire\Project\Service\Index as ServiceIndex;
use App\Http\Livewire\Project\Service\Show as ServiceShow;
@@ -17,6 +16,7 @@ use App\Http\Livewire\Server\Create;
use App\Http\Livewire\Server\Destination\Show as DestinationShow;
use App\Http\Livewire\Server\PrivateKey\Show as PrivateKeyShow;
use App\Http\Livewire\Server\Proxy\Show as ProxyShow;
+use App\Http\Livewire\Server\Proxy\Logs as ProxyLogs;
use App\Http\Livewire\Server\Show;
use App\Http\Livewire\Subscription\Show as SubscriptionShow;
use App\Http\Livewire\Waitlist\Index as WaitlistIndex;
@@ -123,6 +123,7 @@ Route::middleware(['auth'])->group(function () {
Route::get('/server/new', Create::class)->name('server.create');
Route::get('/server/{server_uuid}', Show::class)->name('server.show');
Route::get('/server/{server_uuid}/proxy', ProxyShow::class)->name('server.proxy');
+ Route::get('/server/{server_uuid}/proxy/logs', ProxyLogs::class)->name('server.proxy.logs');
Route::get('/server/{server_uuid}/private-key', PrivateKeyShow::class)->name('server.private-key');
Route::get('/server/{server_uuid}/destinations', DestinationShow::class)->name('server.destinations');
});