mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 15:32:35 +00:00
reverse proxy basics (#609)
This commit is contained in:
@ -51,31 +51,41 @@
|
||||
|
||||
charset utf-8;
|
||||
|
||||
@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
|
||||
@if ($site->port)
|
||||
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;
|
||||
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;
|
||||
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
|
||||
|
||||
|
Reference in New Issue
Block a user