NGINX 404 not found, but file exists… here is a solution to the problem.
NGINX 404 not found, but file exists
I want to call index.html in the folder /var/www/fileUpload/html. The index.html file exists in this folder.
/router works. The same goes for uploadFiles routing. But when I open the upload path, I get a 404 error.
server{
listen 80;
server_name xx.xx.xxx.xxx;
location / {
root /var/www/kioskJPE/html;
index index.html;
}
location /upload {
root /var/www/fileUpload/html;
index index.html;
}
location /uploadFiles {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Do you have any suggestions?
Thanks!
Solution
It should be alias /var/www/fileUpload/html;
Otherwise Nginx is looking for files in /var/www/fileUpload/html/upload/index.html
. See this document for details.
For example:
location /upload {
alias /var/www/fileUpload/html;
}