Created
December 31, 2021 10:10
-
-
Save maxon755/d5df83dc1b96ee001cbcc093c53b6656 to your computer and use it in GitHub Desktop.
Resolving fastcgi_pass depending on the header value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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