I'm setting up multiple Laravel apps under subfolders of a single domain (social network apps, need https, single certificate).
Cannot figure out how to write nginx config to map HTTP requests to /app1/
to a Laravel installation under /var/www/other_folder/public/
Here's the latest iteration of config tests. Debug logging omitted. Laravel root location /app1/ works, but mapping of routes (/app1/api/method/
) does not. Please help, how to either debug how nginx processes the request step by step (debug log is not that explanatory), or give me a hint how to map subfolders of /app1/...
to the index.php
of Laravel.
server {
listen 80;
server_name apps.mydomain.com;
root /var/www/apps.mydomain.com/docs;
location / {
index index.html index.php;
}
location /app1 {
alias /var/www/other_folder/public;
index index.php index.html;
try_files $uri $uri/ /app1/index.php$is_args$args /app1/index.php?$query_string;
}
location ~ /app1/.+\.php$ {
rewrite ^/app1/(.*)$ /$1 break;
include /etc/nginx/fastcgi.conf;
fastcgi_param SCRIPT_FILENAME /var/www/other_folder/public$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_pass php;
# Database access parameters
fastcgi_param DB_HOST "localhost";
fastcgi_param DB_USER "apps";
fastcgi_param DB_PASS "xxxxxxxx";
fastcgi_param DB_NAME "app1";
}
# Other locations skipped
include /etc/nginx/global/php.conf; # other php scripts
}