I've installed Nginx on my Digital Ocean droplet and I've done a build for my react application, now I want to serve the build index.html file to Nginx,
/etc/nginx/sites-enabled/default
:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /root/project-name/dist;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
When I visit the server in the browser I get an 404 message.
The path /root/project-name/dist
is valid:
If I change the root path to:
root /var/www/html;
Then I get the default Nginx page displayed:
The root
and var
folder are both in the same path:
So why can't I point my root to a different folder?