Search code examples
windowsnginxsmbcifs

Host CIFS files on NGINX under Windows


I have NGINX running on a Windows box. I'd really like it to host files which are stored on a neighboring box using CIFS, but I can't figure out how to handle it in the config.

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

When I try pulling a file from that location I get this:

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"

Clearly NGINX is interpreting my command as a relative path.

Is there a way to use a CIFS/SMB UNC path in nginx.conf?

If not, how can I host files stored on a CIFS share?

Many thanks!


Solution

  • Try

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

    And make sure the user/pass on this unc share is the same as the user/pass nginx.exe is using.