Jun 20, 2023
0
Level 1
Error 404 on API with Laravel 10 and Nginx
Hi!
I made a simple API to use a SDK, it receives two parameters, do some checks and return a new value, It's very simple.
When I try locally with php artisan serve, I works nice, I can make the request with a http client.
But when I upload it to my linux vps and configure with nginx, it won´t work, I searched a lot, tryed a lot of settings with params and args on try files, but the problem persists, can anyone give me a hint?
This is my api.php
Route::get('/ali/{url}/{type}', [AliexpressController::class, 'index']);
this is my vhost:
{
listen 5000;
server_name aliapi localhost;
root /var/www/alilinkgen/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
#try_files $uri $uri/ /index.php?$query_string;
index index.html index.htm index.php;
charset utf-8;
location / {
#try_files $uri $uri/ /index.php?$query_string;
try_files $uri $uri/ /index.php$is_args$args;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include conf/fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
I have setted my hosts to 172.0.0.1 aliapi
Can anyone give me a hint about it?
Please or to participate in this conversation.