Dec 12, 2016
0
Level 5
NGINX configuration for multi-tenant PHP application
map $http_accept $api_version {
default 0;
"application/vnd.dev.tenant.api.v1+json" 1;
}
server {
listen 80;
listen [::]:80;
server_name ~^(?<tenant>.+)\.tenant\.dev$;
root /var/www/v$api_version/public;
index index.php;
location / {
if ($api_version = 0) {
root /var/www/app/dist;
}
try_files $uri $uri/ /index.php$is_args$args;
log_not_found off;
error_page 404 =200 /index.html;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_param TENANT $tenant;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
How can I remove if condition from this configuration file? Is there any good way to accomplish this?
Please or to participate in this conversation.