Plugins base (#613)

* wip

* wip

* cleanup

* notification channels

* phpstan

* services

* remove server types

* refactoring

* refactoring
This commit is contained in:
Saeed Vaziry
2025-06-14 14:35:18 +02:00
committed by GitHub
parent adc0653d15
commit 131b828807
311 changed files with 3976 additions and 2660 deletions

View File

@ -0,0 +1,12 @@
#[core]
server_name {{ $site->domain }} {{ $site->getAliasesString() }};
root {{ $site->getWebDirectoryPath() }};
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
charset utf-8;
access_log off;
error_log /var/log/nginx/{{ $site->domain }}-error.log error;
location ~ /\.(?!well-known).* {
deny all;
}
#[/core]

View File

@ -0,0 +1,9 @@
#[force-ssl]
@if ($site->activeSsl && $site->force_ssl)
server {
listen 80;
server_name {{ $site->domain }} {{ $site->getAliasesString() }};
return 301 https://$host$request_uri;
}
@endif
#[/force-ssl]

View File

@ -0,0 +1,6 @@
#[laravel-octane-map]
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
#[/laravel-octane-map]

View File

@ -0,0 +1,25 @@
#[laravel-octane]
index index.php index.html;
error_page 404 /index.php;
location /index.php {
try_files /not_exists @octane;
}
location / {
try_files $uri $uri/ @octane;
}
location @octane {
set $suffix "";
if ($uri = /index.php) {
set $suffix ?$query_string;
}
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Scheme $scheme;
proxy_set_header SERVER_PORT $server_port;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://127.0.0.1:{{ data_get($site->type_data, 'octane_port', 8000) }}$suffix;
}
#[/laravel-octane]

View File

@ -0,0 +1,23 @@
#[load-balancer-upstream]
@php
use App\Enums\LoadBalancerMethod;$backendName = preg_replace("/[^A-Za-z0-9 ]/", '', $site->domain).'_backend';
@endphp
upstream {{ $backendName }} {
@switch($site->type_data['method'] ?? LoadBalancerMethod::ROUND_ROBIN)
@case(LoadBalancerMethod::LEAST_CONNECTIONS)
least_conn;
@break
@case(LoadBalancerMethod::IP_HASH)
ip_hash;
@break
@default
@endswitch
@if ($site->loadBalancerServers()->count() > 0)
@foreach($site->loadBalancerServers as $server)
server {{ $server->ip }}:{{ $server->port }} {{ $server->backup ? 'backup' : '' }} {{ $server->weight ? 'weight='.$server->weight : '' }};
@endforeach
@else
server 127.0.0.1;
@endif
}
#[/load-balancer-upstream]

View File

@ -0,0 +1,13 @@
#[load-balancer]
@php
$backendName = preg_replace("/[^A-Za-z0-9 ]/", '', $site->domain).'_backend';
@endphp
location / {
proxy_pass http://{{ $backendName }}$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
error_page 404 /index.html;
#[/load-balancer]

View File

@ -0,0 +1,19 @@
#[php]
@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
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass {{ $phpSocket }};
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_hide_header X-Powered-By;
}
index index.php index.html;
error_page 404 /index.php;
#[/php]

View File

@ -0,0 +1,12 @@
#[port]
@if (!$site->activeSsl || !$site->force_ssl)
listen 80;
listen [::]:80;
@endif
@if ($site->activeSsl)
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate {{ $site->activeSsl->certificate_path }};
ssl_certificate_key {{ $site->activeSsl->pk_path }};
@endif
#[/port]

View File

@ -0,0 +1,7 @@
#[redirects]
@foreach($site->activeRedirects as $redirect)
location = {{ $redirect->from }} {
return {{ $redirect->mode }} {{ $redirect->to }};
}
@endforeach
#[/redirects]