This is my nginx configuration :-
server {
listen 80 ;
listen [::]:80 ipv6only=on default_server;
access_log /var/log/nginx/mywebsite.log;
error_log /var/log/nginx/mywebsite-error.log;
# server_name server_domain_or_IP;
server_name mywebsite.com www.mywebsite.com ;
location / {
root /home/mywebsite/frontend;
try_files $uri /index.html;
}
location /services/ {
root /home/mywebsite/backend/public;
try_files $uri $uri /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
The directory /home/mywebsite/frontend contain a Reactjs build index.html.
The /home/mywebsite/backend/public contain a laravel framework files.
when i access my website using the URL (mywebsite.com/) the reactjs get loaded very will without any issue, but when i use the URL (mywebsite.com/services/) nginx return error 404.
The error got in /var/log/nginx/mywebsite-error.log :-
[error] 30346#30346: *6 open() "/usr/share/nginx/html/services" failed (2: No such file or directory)
How can i fix that ?