【问题标题】:Host CIFS files on NGINX under Windows在 Windows 下的 NGINX 上托管 CIFS 文件
【发布时间】:2015-07-15 14:33:21
【问题描述】:

我在 Windows 机器上运行 NGINX。我真的很喜欢它来托管使用 CIFS 存储在相邻盒子上的文件,但我不知道如何在配置中处理它。

server {
    listen       80;
    server_name  localhost;
    sendfile off;
    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   html;
        index  index.html index.htm;
    }

    location /share {
        root //otherserver/share/files;
    }
}

当我尝试从该位置提取文件时,我得到以下信息:

2015/05/05 10:28:37 [error] 6600#13064: *12 CreateFile() "C:\Users\me\Desktop\nginx/\\otherserver/share/files/sample.mp4" failed (3: The system cannot find the path specified), client: 127.0.0.1, server: localhost, request: "GET /share/sample.mp4 HTTP/1.1", host: "localhost"

显然 NGINX 将我的命令解释为相对路径。

有没有办法在 nginx.conf 中使用 CIFS/SMB UNC 路径?

如果没有,我如何托管存储在 CIFS 共享上的文件?

非常感谢!

【问题讨论】:

  • 将其挂载为磁盘。但这真是个奇怪的主意
  • 感谢您的评论。在 Linux(和 fstab)下,这将非常简单。因为我在 Windows 环境中,将共享作为磁盘安装是解决这个问题的一种丑陋的解决方案。 (除非我可能在 NTFS 级别这样做......)我想我可以在 nginx 配置中编写一个 exec 脚本,它会按需映射路径......但我觉得必须有一种方法可以在 NGINX 中做到这一点.

标签: windows nginx smb cifs


【解决方案1】:

试试

root "//ip-address/share/files";

并确保此 unc 共享上的用户/密码与 nginx.exe 正在使用的用户/密码相同。

【讨论】:

  • 好的!双引号节省一天!我遇到的唯一另一个问题是我错误地使用了“root”关键字,而我本应该使用“alias”关键字。新配置是: location /share { alias "//otherserver/share/files" } 谢谢!
  • 在提供 Windows 文件路径时不工作...甚至尝试将 \ 转换为 /。没用
猜你喜欢
  • 2016-03-08
  • 2016-06-06
  • 2017-08-27
  • 2016-04-14
  • 2019-03-13
  • 2013-02-28
  • 1970-01-01
  • 1970-01-01
  • 2020-03-02
相关资源
最近更新 更多