8
I'm deploying a Laravel app on nginx. Only the main route works, every other throws me a 404
(lemmy.world)
submitted
2 months ago* (last edited 2 months ago)
by
spirinolas@lemmy.world
to
c/selfhosted@lemmy.world
I developed an app in Laravel that uses Google authentication, it works perfectly on my localhost. When I deployed it in my nginx server (ubuntu 24.04) I get the Google login correctly and it proceeds to my main page as expected. But after that, no route is accessible. All of them throw me a 404. I've been googling it for ages but I can't for the life of me find the solution for this.
EDIT: The 404 comes from Laravel, not nginx. The weird part is if I try php artisan route:list on the ser the routes are indeed missing but on the localhost they all show. The code is pretty much the same.
Here's is my app conf file:
server {
server_name partituras-cmcgb.duckdns.org;
root /var/www/html/partviewer/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
error_log /var/log/nginx/partviewer-error.log;
access_log /var/log/nginx/partviewer-access.log;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/partituras-cmcgb.duckdns.org/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/partituras-cmcgb.duckdns.org/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 = partituras-cmcgb.duckdns.org) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name partituras-cmcgb.duckdns.org;
return 404; # managed by Certbot
}
I was the same until like two months ago when I had to learn Nginx!