I'm deploying a Laravel app on nginx. Only the main route works, every other throws me a 404
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:
<span style="color:#323232;">server {
</span><span style="color:#323232;"> server_name partituras-cmcgb.duckdns.org;
</span><span style="color:#323232;"> root /var/www/html/partviewer/public;
</span><span style="color:#323232;">
</span><span style="color:#323232;"> index index.php index.html index.htm;
</span><span style="color:#323232;">
</span><span style="color:#323232;"> location / {
</span><span style="color:#323232;"> try_files $uri $uri/ /index.php?$query_string;
</span><span style="color:#323232;"> }
</span><span style="color:#323232;">
</span><span style="color:#323232;"> location ~ .php$ {
</span><span style="color:#323232;"> include snippets/fastcgi-php.conf;
</span><span style="color:#323232;"> fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
</span><span style="color:#323232;"> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
</span><span style="color:#323232;"> include fastcgi_params;
</span><span style="color:#323232;"> }
</span><span style="color:#323232;">
</span><span style="color:#323232;"> location ~ /.ht {
</span><span style="color:#323232;"> deny all;
</span><span style="color:#323232;"> }
</span><span style="color:#323232;">
</span><span style="color:#323232;"> error_log /var/log/nginx/partviewer-error.log;
</span><span style="color:#323232;"> access_log /var/log/nginx/partviewer-access.log;
</span><span style="color:#323232;">
</span><span style="color:#323232;"> listen 443 ssl; # managed by Certbot
</span><span style="color:#323232;"> ssl_certificate /etc/letsencrypt/live/partituras-cmcgb.duckdns.org/fullchain.pem; # managed by Certbot
</span><span style="color:#323232;"> ssl_certificate_key /etc/letsencrypt/live/partituras-cmcgb.duckdns.org/privkey.pem; # managed by Certbot
</span><span style="color:#323232;"> include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
</span><span style="color:#323232;"> ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
</span><span style="color:#323232;">
</span><span style="color:#323232;">}
</span><span style="color:#323232;">server {
</span><span style="color:#323232;"> if ($host = partituras-cmcgb.duckdns.org) {
</span><span style="color:#323232;"> return 301 https://$host$request_uri;
</span><span style="color:#323232;"> } # managed by Certbot
</span><span style="color:#323232;">
</span><span style="color:#323232;">
</span><span style="color:#323232;"> listen 80;
</span><span style="color:#323232;"> server_name partituras-cmcgb.duckdns.org;
</span><span style="color:#323232;"> return 404; # managed by Certbot
</span><span style="color:#323232;">
</span><span style="color:#323232;">
</span><span style="color:#323232;">}
</span>