首页 Nginx 根目录在nginx中显示404

根目录在nginx中显示404

我是nginx服务器的新手.我试图为服务图像设置一个新网址“/ images /”.我在启用站点的文件夹中编辑了bi.site文件.server { listen *:80; access_log /var/log/myproject/access_log; location / { proxy_pass

我是nginx服务器的新手.我试图为服务图像设置一个新网址“/ images /”.我在启用站点的文件夹中编辑了bi.site文件.

server {
   listen *:80;
   access_log /var/log/myproject/access_log;
    location / {
        proxy_pass         http://127.0.0.1:5000/;
        proxy_redirect     off;

        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
    location /images/ {
        root /www/myproject/files_storage;
    }

}

在/ www / myproject / files_storage位置我输入了一个temp.txt文件.

当我把http://www.main_url/images/temp.txt它显示404找不到.我究竟做错了什么 ?我错过了重要的事吗?

最佳答案
这个:

location /images/ {
        root /www/myproject/files_storage;
    }

结果在/ www / myproject / files_storage / images路径中,如果你设置error_log就很明显了.所以使用“alias”指令代替“root”

http://nginx.org/en/docs/http/ngx_http_core_module.html#alias

本文来自网络,不代表青岛站长网立场。转载请注明出处: https://www.0532zz.com/html/yunying/nginx/20210123/16752.html
上一篇
下一篇

作者: dawei

【声明】:青岛站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

返回顶部