Skip to content

Instantly share code, notes, and snippets.

@maxon755
Created December 31, 2021 10:10
Show Gist options
  • Save maxon755/d5df83dc1b96ee001cbcc093c53b6656 to your computer and use it in GitHub Desktop.
Save maxon755/d5df83dc1b96ee001cbcc093c53b6656 to your computer and use it in GitHub Desktop.
Resolving fastcgi_pass depending on the header value
upstream dev_backend {
server dev-php:9000;
}
upstream test_backend {
server test-php:9000;
}
map $http_x_testing_mode $php_backend {
"true" "test_backend";
default "dev_backend";
}
server {
listen 80;
server_name localhost;
root /code/public;
index index.php;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_pass $php_backend;
try_files $uri=404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment