Update the vhost file to name the backend after the domain (#485)

This commit is contained in:
Austin Kregel 2025-02-15 03:33:40 -05:00 committed by GitHub
parent fd67097884
commit 75a4fde8de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,8 +6,12 @@
}
@endif
@php
$backendName = preg_replace("/[^A-Za-z0-9 ]/", '', $site->domain).'_backend';
@endphp
@if ($site->type === \App\Enums\SiteType::LOAD_BALANCER)
upstream backend {
upstream {{ $backendName }} {
@switch($site->type_data['method'] ?? \App\Enums\LoadBalancerMethod::ROUND_ROBIN)
@case(\App\Enums\LoadBalancerMethod::LEAST_CONNECTIONS)
least_conn;
@ -67,7 +71,7 @@
@if ($site->type === \App\Enums\SiteType::LOAD_BALANCER)
location / {
proxy_pass http://backend$request_uri;
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;