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, but it renders 403 Forbidden on my specified location. The default root provided inside the server just works fine.
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;
}
}
HHVM Upstream When I try site.local the hhvm upstream just works fine and the page is successfully rendered.
PHP Upstream When I try http://site.local/catalog/category/view/id/11 I get a 403 forbidden error and I see this in nginx error log
> site_openresty | 2018/05/21 11:34:43 [error] 6#6: *1 directory index
> of "/srv/project2/public" is forbidden, client: 172.19.0.1, server:
> site.local, request: "GET /catalog/category/view/id/11/??? HTTP/1.1",
> host: "site.local"
I have been trying this for 3 days now and tried different solutions provided on Stackoverflow, github and serverfault but none seems to be fixing my problem.