Files
vito/resources/views/ssh/services/webserver/caddy/vhost.blade.php
Rasel Islam Rafi 984c1f3a8e Add Caddy Server Support Alongside Nginx (#600)
* added enum

* add config for caddy

* add svg icon

* add caddy service class

* wip

* install caddy

* create base Caddyfile with common snippets

* Create a systemd service to run Caddy in the background.

* create uninstall file

* wip

* create path

* create vhost

* get vhost

* delete site

* add php version change file

* add custom ssl

* create redirect file

* add vhost for caddy site & load balancer

* update svg

* fix caddy icon

* fix style

* add systemctl reload method

* Reload systemd after modifying the Caddy service file.

* add caddy

* added tests

* format with pint

* prevent multiple web server installations

* added error log & access log

(cherry picked from commit 2318e1b1df)
2025-05-29 11:39:00 +02:00

47 lines
1.8 KiB
PHP
Executable File

{{ $site->domain }} {{ $site->getAliasesString() }} {
@if ($site->activeSsl)
tls {{ $site->activeSsl->certificate_path }} {{ $site->activeSsl->pk_path }}
@endif
@if ($site->activeSsl && $site->force_ssl)
redir @http https://{host}{uri} permanent
@endif
import access_log {{ $site->domain }}
import compression
import security_headers
@if ($site->type()->language() === 'php')
root * {{ $site->getWebDirectoryPath() }}
@php
$phpSocket = "unix//var/run/php/php{$site->php_version}-fpm.sock";
if ($site->isIsolated()) {
$phpSocket = "unix//run/php/php{$site->php_version}-fpm-{$site->user}.sock";
}
@endphp
try_files {path} {path}/ /index.php?{query}
php_fastcgi {{ $phpSocket }}
file_server
@endif
@if ($site->type === \App\Enums\SiteType::LOAD_BALANCER)
reverse_proxy {
@if ($site->loadBalancerServers()->count() > 0)
@foreach($site->loadBalancerServers as $server)
to {{ $server->ip }}:{{ $server->port }}
@endforeach
@else
to 127.0.0.1
@endif
@switch($site->type_data['method'] ?? \App\Enums\LoadBalancerMethod::ROUND_ROBIN)
@case(\App\Enums\LoadBalancerMethod::LEAST_CONNECTIONS)
lb_policy least_conn
@break
@case(\App\Enums\LoadBalancerMethod::IP_HASH)
lb_policy ip_hash
@break
@default
lb_policy round_robin
@endswitch
header_up Host {host}
header_up X-Real-IP {remote}
}
@endif
@include('ssh.services.webserver.caddy.redirects', ['site' => $site])
}