Skip to content

Commit

Permalink
Update the vhost file to name the backend after the domain
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkregel committed Feb 14, 2025
1 parent fd67097 commit c7bb2b8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions resources/views/ssh/services/webserver/nginx/vhost.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c7bb2b8

Please sign in to comment.