Linux용 다중 사용자 webdav 서버가 있습니까?

Linux용 다중 사용자 webdav 서버가 있습니까?

SMBA 서비스를 완전히 중단하고 WebDav 서비스로 교체하고 싶습니다.

지금까지 모든 Google 검색에서는 Apache/Webdav를 사용하는 것으로 나타났습니다. 이것은 내가 필요한 것과 가깝지만 내가 아는 한 내 사용자의 파일에 액세스하려면 Apache가 필요하며, 더 나쁜 경우 파일을 생성하는 경우 새 파일은 사용자가 아닌 Apache가 소유하게 됩니다. 일부 사용자는 SSH에 직접 액세스할 수 있으므로 파일에 대한 올바른 Unix 소유권과 권한이 필요합니다.

그래서 저는 Apache/Webdav가 여러 사용자와 "올바르게" 작동하도록 하는 방법을 찾고 있습니다(예:파일 제공을 시도하기 전에 unix 사용자를 로그인한 사용자로 변경하십시오.) 또는 Apache/Webdav의 완전한 대체품을 찾으세요.

검색해본 결과 지금까지 아무 것도 나오지 않았습니다.

답변1

사용자 이름 및/또는 uid가 있으면 nginx + lua + luarocks ljsyscall을 사용하여 이 작업을 수행할 수 있습니다.

데비안 시스템에서 구성은 다음과 같습니다:

apt-get -y install nginx libnginx-mod-http-dav-ext libnginx-mod-http-lua luarocks
luarocks install ljsyscall

nginx 구성은 다음과 같습니다.

user  root;
worker_processes  1;

load_module modules/ngx_http_dav_ext_module.so;
load_module modules/ndk_http_module.so;
load_module modules/ngx_http_lua_module.so;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    sendfile        on;
    keepalive_timeout  65;
    gzip  on;

    server {
        listen      80;
        listen [::]:80;

        location / {
            rewrite ^ http://$host$request_uri?; # permanent;
        }
    }

    server {
        listen      443           ssl http2;
        listen [::]:443           ssl http2;

        ssl                       on;    
        # [ SSL Sections Omitted ]

        # Set the maximum size of uploads
        client_max_body_size 200m;

        # Default is 60, May need to be increased for very large uploads
        client_body_timeout 120s; 

        # other configs
        location /webdav/ {
            autoindex              on;
            alias                  /data/www/;
            client_body_temp_path  /data/client_temp;

            dav_methods PUT DELETE MKCOL COPY MOVE;
            dav_ext_methods PROPFIND OPTIONS;

            create_full_put_path   on;
            # Not sure if you want to tweak this
            # dav_access             group:rw  all:r;

            # Let's assume you have an auth subrequest that can set X-UID
            auth_request  /auth
            auth_request_set $auth_status $upstream_status;
            auth_request_set $saved_remote_user $upstream_http_REMOTE_USER;
            auth_request_set $saved_remote_uid $upstream_http_X_UID;

            # Per-Request Impersonation
            access_by_lua_block {
                # Boilerplate because ljsyscall doesn't have setfsuid implemented directly
                local syscall_api = require 'syscall'
                local ffi = require "ffi"
                local nr = require("syscall.linux.nr")
                local sys = nr.SYS
                local uint = ffi.typeof("unsigned int")
                local syscall_long = ffi.C.syscall -- returns long
                local function syscall(...) return tonumber(syscall_long(...)) end 
                local function setfsuid(id) return syscall(sys.setfsuid, uint(id)) end
                -- If you only have ngx.var.saved_remote_user, install luaposix and do this ...
                -- local pwd = require 'posix.pwd'
                -- local new_uid = pwd.getpwnam(ngx.saved_remote_user).pw_uid
                local new_uid = tonumber(ngx.var.saved_remote_uid)
                ngx.log(ngx.NOTICE, "[Impersonating User #" .. new_uid .. "]")
                local previous = setfsuid(new_uid)
                local actual = setfsuid(new_uid)
                if actual ~= new_uid then
                    ngx.log(ngx.CRIT, "Unable to impersonate users")
                    ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
                end
            }
        }

        location = /auth {
            internal;
            proxy_pass              http://localhost:8080/auth;
            proxy_pass_request_body off;
            proxy_set_header        Content-Length "";
            proxy_set_header        X-Original-URI $request_uri;
            proxy_set_header        X-Original-Method $request_method;
        }
    }
}

그러면 nginx 작업자 스레드가 제공하는 모든 요청에 ​​대해 setfsuid가 실행됩니다. 불행하게도 이것이 작동하려면 nginx를 루트로 실행해야 하는 것 같습니다. 프로세스가 루트로 시작되고 다른 사용자에게 삭제되고 CAP_SETUID가 보존되고(문서 참조 capsh) user해당 지시문이 nginx 구성 파일에 없으면 다른 사용자와도 작동할 것이라고 믿습니다.

그룹 ID를 설정해야 할 수도 있습니다.

사용자 ID 변경이 기능에 미치는 영향 보기 http://man7.org/linux/man-pages/man7/capability.7.html

답변2

오랫동안 검색했는데도 찾을 수 없었습니다. 다중 사용자 서버는 많지만 시스템 사용자로 실행되는 서버는 찾을 수 없습니다.

그래서 제가 직접 하나 썼습니다. 이것은 제가 직접 테스트한 것입니다. 그러나 어쨌든 소스 코드는 다음과 같습니다.

https://github.com/couling/WebDAV-데몬

답변3

여기요,

나는 똑같은 것을 찾고 있었고 마침내 apache2를 사용하여 솔루션을 모았습니다. npm webdav-server를 사용하여 노드 솔루션을 시도한 결과 모든 솔루션이 Apache 모듈을 사용하는 것만큼 좋지는 않다는 것을 발견했습니다. 그런 다음 더 나은 성능을 발휘하고 해결책이 될 수 있는 jsDAV 기반의 npm dav-server를 시도했지만 형편없는 3g 연결을 처리해야 했기 때문에 Apache를 선호했고 여러 인스턴스 스크립트를 찾았습니다.

그래서 여기에 내 경험을 공유합니다.

http://helpcenter.epages.com/Doc/doc/apache2/README.multiple-instances

저는 webdav 사용자당 하나의 인스턴스를 실행합니다. 확장성이 뛰어나지는 않지만 소규모 팀에서 작업하기에 충분합니다.

myUser를 사용자로 바꾸십시오.

우분투 14.04에서

sh /usr/share/doc/apache2/examples/setup-instance myUser

그래서 /etc/apache2-myUser/envars에 정의된 myUser 사용자로 Apache 프로세스를 실행합니다.

export APACHE_RUN_USER=myUser
export APACHE_RUN_GROUP=myUser

ports.conf 편집

# If you proxy with nginx as I did better to limit to local interface
listen localhost:8080
# listen 8080

우분투 14.04에서는 PAM 인증을 사용할 수 없으므로 기본 인증으로 스푸핑한 다음 nginx를 사용하여 https로 래핑해야 합니다.

htpasswd -c /etc/apache2/htpasswd myUser

그런 다음 /etc/apache2-myUser/sites-available/000-default.conf

<VirtualHost *:8080>

DocumentRoot /var/www/html

Alias /${APACHE_RUN_USER} /home/${APACHE_RUN_USER}
<Directory /home/${APACHE_RUN_USER}>
    Require all granted
    Options +Indexes
</Directory>

<Location /${APACHE_RUN_USER}>
      DAV On
      AuthType Basic
      AuthName "Restricted Area"
      AuthUserFile /etc/apache2/htpasswd
      Require valid-user
</Location>

DavLockDB /home/${APACHE_RUN_USER}/.DavLock
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

그런 다음 nginx 프록시에는 브라우저에서 webdav의 성능이 저하되도록 헤더 Destination을 통해 아이콘 폴더를 전달하는 트릭이 있습니다.

server {
listen 443 ssl http2;
server_name exemple.com;

location ~ ^/(myUser|icons)/ {

    proxy_pass http://dav-myUser;

#         auth_basic "Restricted Content";
#         auth_basic_user_file /etc/nginx/htpasswd;

#         proxy_set_header Authorization $http_authorization;

    proxy_pass_header  Authorization;
    proxy_pass_request_headers on;

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;

    port_in_redirect off;

    # to avoid 502 Bad Gateway:
    # http://vanderwijk.info/Members/ivo/articles/ComplexSVNSetupFix
    set $destination $http_destination;

    if ($destination ~* ^https(.+)$) {
        set $destination http$1;
    }

    proxy_set_header Destination $destination;

    proxy_read_timeout     300;
    proxy_connect_timeout  5;

    # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
    proxy_http_version 1.1;

    # Remove the Connection header if the client sends it,
    # it could be "close" to close a keepalive connection
    proxy_set_header Connection "";
}

ssl on;
ssl_certificate /etc/letsencrypt/live/exemple.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/exemple.com/privkey.pem;

include /etc/letsencrypt/options-ssl-nginx.conf;

}

nginx를 프록시로 사용해야 할 의무는 없습니다. Apache는 https를 잘 수행하지만 프록시 대상에 문제가 발생했을 때 언급할 가치가 있다고 생각했습니다.

답변4

SFTPGO사용자 및 권한을 추가/제거할 수 있는 관리 UI가 있습니다. 그런 다음 webdav, ftp 및 sftp 포트를 열고 거기에서 파일을 호스팅합니다. 사용자는 세 가지 프로토콜 모두에 대해 동일한 사용자 이름/비밀번호를 사용할 수 있습니다.

관련 정보