加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

根目录在nginx中显示404

发布时间:2020-12-13 21:30:27 所属栏目:Nginx 来源:网络整理
导读:我是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;

我是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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读