Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
selfhost:fileserver [2024/01/16 10:44] – willy | selfhost:fileserver [2025/03/19 15:09] (current) – willy | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== File Server ====== | + | ====== |
+ | I will not discuss how to share your files on the home network using __legacy__ tools like [[https:// | ||
- | Access | + | I will focus on how to provide access via __web browser__ and via __WebDAV__, which is a web-based sharing protocol a bit like NFS or SAMBA, but aimed ad broader //in**ter**net// access, |
- | Access must be both from web page (HTTP/ | + | The idea is to create share areas where your users will be able to store files. It is possible to extend this idea also to user-specific areas where each user can put private stuff not visible by other users, but this require a little bit extra complexity |
- | [[sailing: | + | You will be using your SSO authentication, |
- | [[sailing:NGINX]] is used as WebDAV server. | + | In the past i used a more complex solution leveraging more tools. That obsolete solution has been moved, for reference, |
- | ===== Background | + | ===== Overall Architecture and Shares |
- | From users point of view, the common area will be managed by user **filebrowser** | + | This solution leverages |
- | Of course, each user will need to be part of the **users** group as well. | + | AList itself also support SSO integration, opening the way to provide also a public sharing approach, if needed since the SSO should not be enabled at reverse-proxy level. |
- | You will need a common " | + | You can also define as many shared folders as you like, and even connect |
- | This folder will need to contain: | + | |
- | * **common** subfolder, where the common area files will be stored (created in the [[sailing: | + | |
- | * **temp/ | + | |
- | * **temp/ | + | |
- | * **temp/ | + | |
- | * **logs** subfolder, to store NGINX log files | + | |
- | * **conf** subfolder, where you will store custom NGINX config files for the private areas (and common area too) | + | |
- | Create the folders: | + | I will assume that your shares are under **/data/shares**, but of course each share can be located anywhere you like. Let's also assume, as an example, that your share is called __/data/shares/common__ and is managed by the user __fileserver__ of the group __users__. The requirement for users and groups will be detailed later on. |
- | <code bash> | + | |
- | > mkdir /data/archive | + | |
- | > mkdir /data/archive/logs | + | |
- | > mkdir / | + | |
- | > mkdir / | + | |
- | > mkdir / | + | |
- | > mkdir / | + | |
- | > mkdir / | + | |
- | > chown filebrowser: | + | |
- | </ | + | |
- | ===== NGINX WebDAV approach ===== | + | Each share folder will have the following structure: |
+ | * / | ||
+ | * / | ||
+ | * / | ||
- | No need to use third party WebDAV server since NGINX has a pretty solid implementation of it already. Follow the [[sailing: | + | Your AList installation will provide WebDAV and browser access from one single port hwich need to be reverse-proxied. |
- | Now, there is a nasty catch here which stems from using NGINX as WebDAV | + | I choose to assign |
+ | * **https:// | ||
+ | * **https://drive.mydomain.com/common**: direct browser access URL for __common__ | ||
+ | * **https:// | ||
+ | * **https:// | ||
+ | * **https:// | ||
+ | * **https:// | ||
- | For consistency, this NGINX config file will be **/data/archive/ | + | I think that /webdav is easier to remember than /dav, but AList by default shared WebDAV under /dav, NGINX will be used to map the /webdav path to /dav. |
- | <file txt / | + | |
- | worker_processes 1; | + | |
- | pid / | + | |
- | error_log / | + | |
- | events { | + | You can add any more folders as separate shares as you like. Due to how WebDAV works, it is mandatory to separate the browser accessible URLs from the WebDAV ones, like i did above. |
- | worker_connections 100; | + | |
- | use epoll; | + | |
- | } | + | |
- | http { | ||
- | include / | ||
- | default_type application/ | ||
- | # These folder MUST be redirected to avoid usage of system wide ones: | + | === Permissions and Users === |
- | client_body_temp_path | + | |
- | proxy_temp_path | + | |
- | fastcgi_temp_path | + | |
- | uwsgi_temp_path | + | |
- | scgi_temp_path | + | |
- | disable_symlinks off; | + | |
- | keepalive_timeout 75 20; | + | (Note: you should run AList as the user **fileserver** and group **users**) |
- | server { | + | I assume you have already created the user **fileserver** when installing AList. |
- | server_name 127.0.0.1; | + | |
- | access_log | + | You need to set the //umask// for the fileserver |
- | location / { | + | <code bash> |
- | root / | + | mkdir /data/shares |
- | + | mkdir /data/shares/common | |
- | dav_methods PUT DELETE MKCOL COPY MOVE; | + | chown fileserver:users /data/shares |
- | dav_ext_methods PROPFIND OPTIONS; | + | |
- | dav_access | + | |
- | + | ||
- | client_max_body_size 0; | + | |
- | create_full_put_path on; | + | |
- | client_body_temp_path / | + | |
- | } | + | |
- | listen 10000; | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | This NGINX server will listen on 127.0.0.1: | + | |
- | <file txt webdav.conf> | + | |
- | location ~ ^/webdav/common { | + | |
- | | + | |
- | | + | |
- | } | + | |
- | </ | + | |
- | and including it into the main NGINX server. | + | |
- | + | ||
- | Now, edit the **/data/daemons/ | + | |
- | < | + | |
- | nginx -c / | + | |
</ | </ | ||
- | like this: | ||
- | <file bash filebrowser.sh> | ||
- | #!/bin/bash | ||
- | cd / | + | ===== Fileserver access via Browser ===== |
- | nginx -c / | + | |
- | ./ | + | |
- | </ | + | |
- | and restart filebrwoser and the main NGINX. | + | Nothing extra needs to be done except install AList, |
- | At this point, your common area will be ready and working both on WebDAV and directly via web browser. | ||
- | |||
- | To access via browser: | ||
- | |||
- | to access via WebDAV clients: | ||
+ | ===== Fileserver access via WebDAV ===== | ||
+ | __NOTE:__ using HTTP will cause a 301 redirect to HTTPS, and WebDAV clients will fail. So use HTTPS URL in webdav clients and not HTTP. | ||
+ | The only chnage you need to make is to add the following location to the NGINX configuration file you created during AList setup: | ||
+ | < | ||
+ | location /webdav/ { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | which will remap /webdav to /dav | ||