Nginx not found 404 error means Nginx can’t find the resources your web browser asks for.
- Check web root directory exists on your server.
- Make sure your website files are stored in the correct directory.
To resolve "Nginx not found 404 error", please find below workarounds if helpful:
Workaround1:
The most likely issue is that you're not telling Nginx to forward
other requests to the /index.html of your application, which makes it
so your other pages can't be loaded directly and display a 404 error.
To fix this, you'll need to make a small change to your Nginx
configuration files.
Make sure your nginx.conf
file as shown below:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
location / {
root /home/user_name/Documents/your_proj; # You need to provide here the path of your "index.html" file
index index.html index.htm;
}
}
Workaround2:
If Workaround1 does not work, try changing the location segment
as below
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.html break;
}
}
Workaround3:
Configure the startup command on "Settings > General settings > Startup Command".
Change the path to your build path.
To redirect all queries, use the --spa
option:
pm2 serve /home/site/wwwroot/client/build --no-daemon --spa
Workaround4:
In the nginx.conf
file, try commenting-out the disable_symlinks on
line or changing it to disable_symlinks off
.