mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 07:22:34 +00:00
Plugins base (#613)
* wip * wip * cleanup * notification channels * phpstan * services * remove server types * refactoring * refactoring
This commit is contained in:
@ -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]
|
@ -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]
|
@ -0,0 +1,6 @@
|
||||
#[laravel-octane-map]
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
#[/laravel-octane-map]
|
@ -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]
|
@ -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]
|
@ -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]
|
@ -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]
|
@ -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]
|
@ -1,5 +1,7 @@
|
||||
#[redirects]
|
||||
@foreach($site->activeRedirects as $redirect)
|
||||
location = {{ $redirect->from }} {
|
||||
return {{ $redirect->mode }} {{ $redirect->to }};
|
||||
}
|
||||
@endforeach
|
||||
#[/redirects]
|
115
resources/views/ssh/services/webserver/nginx/vhost.blade.php
Executable file → Normal file
115
resources/views/ssh/services/webserver/nginx/vhost.blade.php
Executable file → Normal file
@ -1,102 +1,19 @@
|
||||
@if ($site->activeSsl && $site->force_ssl)
|
||||
server {
|
||||
listen 80;
|
||||
server_name {{ $site->domain }} {{ $site->getAliasesString() }};
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
@endif
|
||||
|
||||
@php
|
||||
$backendName = preg_replace("/[^A-Za-z0-9 ]/", '', $site->domain).'_backend';
|
||||
@endphp
|
||||
|
||||
@if ($site->type === \App\Enums\SiteType::LOAD_BALANCER)
|
||||
upstream {{ $backendName }} {
|
||||
@switch($site->type_data['method'] ?? \App\Enums\LoadBalancerMethod::ROUND_ROBIN)
|
||||
@case(\App\Enums\LoadBalancerMethod::LEAST_CONNECTIONS)
|
||||
least_conn;
|
||||
@break
|
||||
@case(\App\Enums\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
|
||||
}
|
||||
@endif
|
||||
#[header]
|
||||
@foreach($header ?? [] as $header)
|
||||
{{ $header }}
|
||||
@endforeach
|
||||
#[/header]
|
||||
|
||||
server {
|
||||
@if (!$site->activeSsl || !$site->force_ssl)
|
||||
listen 80;
|
||||
@endif
|
||||
@if ($site->activeSsl)
|
||||
listen 443 ssl;
|
||||
ssl_certificate {{ $site->activeSsl->certificate_path }};
|
||||
ssl_certificate_key {{ $site->activeSsl->pk_path }};
|
||||
@endif
|
||||
|
||||
server_name {{ $site->domain }} {{ $site->getAliasesString() }};
|
||||
root {{ $site->getWebDirectoryPath() }};
|
||||
|
||||
add_header X-Frame-Options "SAMEORIGIN";
|
||||
add_header X-Content-Type-Options "nosniff";
|
||||
|
||||
index index.html index.php;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
@if ($site->port)
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:{{ $site->port }};
|
||||
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;
|
||||
}
|
||||
@else
|
||||
@if ($site->type()->language() === '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;
|
||||
}
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@if ($site->type === \App\Enums\SiteType::LOAD_BALANCER)
|
||||
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;
|
||||
}
|
||||
@endif
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
error_page 404 /index.html;
|
||||
|
||||
location ~ /\.(?!well-known).* {
|
||||
deny all;
|
||||
}
|
||||
|
||||
@include('ssh.services.webserver.nginx.redirects', ['site' => $site])
|
||||
#[main]
|
||||
@foreach($main ?? [] as $main)
|
||||
{{ $main }}
|
||||
@endforeach
|
||||
#[/main]
|
||||
}
|
||||
|
||||
#[footer]
|
||||
@foreach($footer ?? [] as $footer)
|
||||
{{ $footer }}
|
||||
@endforeach
|
||||
#[/footer]
|
||||
|
Reference in New Issue
Block a user