找不到 NGINX 404 但文件存在

NGINX 404 not found but file exists

我想从文件夹 /var/www/fileUpload/html 调用 index.html。 index.html 文件存在于该文件夹中。

/ 路由器正常工作。 uploadFiles 路由也是如此。但是当我打开上传路径时,出现 404 错误。

    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;
    }
}

你有什么建议吗? 谢谢!

那应该是 alias /var/www/fileUpload/html; 否则 Nginx 正在寻找 /var/www/fileUpload/html/upload/index.html 中的文件。有关详细信息,请参阅 this document

例如:

location /upload {
    alias /var/www/fileUpload/html;
}