I have two projects with the different path locations that need to be configured under a single domain with separate upstream PHP 7.1 and HHVM. I am trying to achieve the goal with nginx alias directive and it looks like that try_files directive does not play well with try_files. Is there a way to achieve something similar to that using openresty and lua. FOr instance I would like to dynamically change the document root based on the path loaded from MYSQL or REDIS.
Here is the nginx code.
server {
listen 80;
listen [::]:80;
server_name site.local;
root /srv/project1;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
#This renders a 403 forbidden
location ~ /catalog/category/view/id {
alias /srv/project2/public;
index index.laravel.php;
if (!-e $request_filename) { rewrite ^ index.laravel.php last; }
location ~ \.laravel\.php$ {
if (!-f $request_filename) { return 404; }
include fastcgi_params;
fastcgi_pass php-upstream;
fastcgi_index index.laravel.php;
fastcgi_param SCRIPT_FILENAME $document_root$request_filename;
}
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass hhvm-upstream;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}