I am trying to serve laravel from a /location block in a Ubuntu nginx virtual host configuration. I have the laravel application installed and working fine when accessed directly but the nginx location block seems like not doing what it is expected to do.
This works : https://www.madol.example.com/horizontal-laravel/public/index.php
This doesn't (403): https://www.madol.example.com/horizontal-laravel/
Note: Real address omitted.
Main snippets which might be wrong:
root /var/www/madol.example.com;
server_name madol.example.com www.madol.example.com;
location /horizontal-laravel {
try_files $uri $uri/ /horizontal-laravel/public/index.php;
}
Here is the full code from my config file-
server {
root /var/www/madol.example.com;
index index.php index.html;
server_name madol.example.com www.madol.example.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
include snippets/fastcgi-php.conf;
}
**# Something wrong here?**
location /horizontal-laravel {
try_files $uri $uri/ /horizontal-laravel/public/index.php;
}
location ~* \.(jpg|jpeg|png|gif|svg|ico|css|js)$ {
expires 7d;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/madol.madcoderz.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/madol.madcoderz.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.madol.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = madol.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name madol.example.com www.madol.example.com;
return 404;
} # managed by Certbot
Is there any other config issues apart from this in the code?