Configuration

This document describes the configuration options of a WsgiDAV server.

The WsgiDAVApp object is configured by passing a Python dict with distinct options, that define

  • Server options (hostname, port, SSL cert, …)

  • List of share-name / WebDAV provider mappings

  • Optional list of users for authentication

  • Optional custom DAV providers (i.e. other than FilesystemProvider)

  • Optional custom lock manager, property manager and domain controller

  • Advanced debugging options

  • (and more)

This section shows the available options and defaults:

  1# -*- coding: utf-8 -*-
  2# (c) 2009-2023 Martin Wendt and contributors; see WsgiDAV https://github.com/mar10/wsgidav
  3# Original PyFileServer (c) 2005 Ho Chun Wei.
  4# Licensed under the MIT license:
  5# http://www.opensource.org/licenses/mit-license.php
  6r"""
  7::
  8
  9     _      __         _ ___  ___ _   __
 10    | | /| / /__ ___  (_) _ \/ _ | | / /
 11    | |/ |/ (_-</ _ `/ / // / __ | |/ /
 12    |__/|__/___/\_, /_/____/_/ |_|___/
 13               /___/
 14
 15Default confguration.
 16"""
 17# from wsgidav.mw.debug_filter import WsgiDavDebugFilter
 18from wsgidav.dir_browser import WsgiDavDirBrowser
 19from wsgidav.error_printer import ErrorPrinter
 20from wsgidav.http_authenticator import HTTPAuthenticator
 21from wsgidav.mw.cors import Cors
 22from wsgidav.request_resolver import RequestResolver
 23
 24__docformat__ = "reStructuredText"
 25
 26# Use these settings, if config file does not define them (or is totally missing)
 27DEFAULT_VERBOSE = 3
 28DEFAULT_LOGGER_DATE_FORMAT = "%H:%M:%S"
 29DEFAULT_LOGGER_FORMAT = "%(asctime)s.%(msecs)03d - %(levelname)-8s: %(message)s"
 30
 31DEFAULT_CONFIG = {
 32    "server": "cheroot",
 33    "server_args": {},
 34    "host": "localhost",
 35    "port": 8080,
 36    "mount_path": None,  # Application root, e.g. <mount_path>/<share_name>/<res_path>
 37    "provider_mapping": {},
 38    "add_header_MS_Author_Via": True,
 39    "hotfixes": {
 40        "emulate_win32_lastmod": False,  # True: support Win32LastModifiedTime
 41        "re_encode_path_info": True,  # (See issue #73)
 42        "unquote_path_info": False,  # (See issue #8, #228)
 43        # "treat_root_options_as_asterisk": False, # Hotfix for WinXP / Vista: accept 'OPTIONS /' for a 'OPTIONS *'
 44        # "win_accept_anonymous_options": False,
 45        # "winxp_accept_root_share_login": False,
 46    },
 47    "property_manager": None,  # True: use property_manager.PropertyManager
 48    "mutable_live_props": [],
 49    "lock_storage": True,  # True: use LockManager(lock_storage.LockStorageDict)
 50    "middleware_stack": [
 51        # WsgiDavDebugFilter,
 52        Cors,
 53        ErrorPrinter,
 54        HTTPAuthenticator,
 55        WsgiDavDirBrowser,  # configured under dir_browser option (see below)
 56        RequestResolver,  # this must be the last middleware item
 57    ],
 58    # HTTP Authentication Options
 59    "http_authenticator": {
 60        # None: dc.simple_dc.SimpleDomainController(user_mapping)
 61        "domain_controller": None,
 62        "accept_basic": True,  # Allow basic authentication, True or False
 63        "accept_digest": True,  # Allow digest authentication, True or False
 64        "default_to_digest": True,  # True (default digest) or False (default basic)
 65        # Name of a header field that will be accepted as authorized user
 66        "trusted_auth_header": None,
 67    },
 68    #: Used by SimpleDomainController only
 69    "simple_dc": {"user_mapping": {}},  # NO anonymous access by default
 70    #: Verbose Output
 71    #: 0 - no output
 72    #: 1 - no output (excepting application exceptions)
 73    #: 2 - show warnings
 74    #: 3 - show single line request summaries (for HTTP logging)
 75    #: 4 - show additional events
 76    #: 5 - show full request/response header info (HTTP Logging)
 77    #:     request body and GET response bodies not shown
 78    "verbose": DEFAULT_VERBOSE,
 79    #: Log options
 80    "logging": {
 81        "logger_date_format": DEFAULT_LOGGER_DATE_FORMAT,
 82        "logger_format": DEFAULT_LOGGER_FORMAT,
 83        "enable_loggers": [],
 84        "debug_methods": [],
 85    },
 86    #: Options for `WsgiDavDirBrowser`
 87    "dir_browser": {
 88        "enable": True,  # Render HTML listing for GET requests on collections
 89        # Add a trailing slash to directory URLs (by generating a 301 redirect):
 90        "directory_slash": True,
 91        # List of fnmatch patterns:
 92        "ignore": [
 93            ".DS_Store",  # macOS folder meta data
 94            "._*",  # macOS hidden data files
 95            "Thumbs.db",  # Windows image previews
 96        ],
 97        "icon": True,
 98        "response_trailer": True,  # Raw HTML code, appended as footer (True: use a default)
 99        "show_user": True,  # Show authenticated user an realm
100        # Send <dm:mount> response if request URL contains '?davmount' (rfc4709)
101        "davmount": True,
102        # Add 'Mount' link at the top
103        "davmount_links": False,
104        "ms_sharepoint_support": True,  # Invoke MS Office documents for editing using WebDAV
105        "libre_office_support": True,  # Invoke Libre Office documents for editing using WebDAV
106        # The path to the directory that contains template.html and associated assets.
107        # The default is the htdocs directory within the dir_browser directory.
108        "htdocs_path": None,
109    },
110}

When a Python dict is passed to the WsgiDAVApp constructor, its values will override the defaults from above:

root_path = gettempdir()
provider = FilesystemProvider(root_path)

config = {
    "host": "0.0.0.0",
    "port": 8080,
    "provider_mapping": {"/": provider},
    "verbose": 1,
    }
app = WsgiDAVApp(config)

Use a Configuration File

When running from the CLI (command line interface), some settings may be passed as arguments, e.g.:

$ wsgidav --host=0.0.0.0 --port=8080 --root=/tmp --auth=anonymous

Serving on http://0.0.0.0:8080 ...

Much more options are available when a configuration file is used. By default wsgidav.yaml and wsgidav.json are searched in the local directory. An alternative file name can be specified like so:

$ wsgidav --config=my_config.yaml

To prevent the use of a local default configuration file, use this option:

$ wsgidav --no-config

The options described below can be defined for the CLI either

  • in YAML syntax inside a wsgidav.yaml file

  • or JSON syntax inside a wsgidav.json file

Note

The two supported file formats are just different ways for the CLI to generate a Python dict that is then passed to the WsgiDAVApp constructor.

The YAML format is recommended.

For a start, copy YAML Sample Configuration and edit it to your needs. (Alternatively use JSON Sample Configuration.)

Verbosity Level

The verbosity level can have a value from 0 to 5 (default: 3):

Verbosity

Option

Log level

Remarks

0

-qqq

CRITICAL

quiet

1

-qq

ERROR

no output (excepting application exceptions)

2

-q

WARN

warnings and errors only

3

INFO

show single line request summaries (for HTTP logging)

4

-v

DEBUG

show additional events

5

-vv

DEBUG

show full request/response header info (HTTP Logging) request body and GET response bodies not shown

Middleware Stack

WsgiDAV is built as WSGI application (WsgiDAVApp) that is extended by a list of middleware components which implement additional functionality.

This stack is defined as a list of WSGI compliant application instances, e.g.:

from wsgidav.mw.debug_filter import WsgiDavDebugFilter

debug_filter = WsgiDavDebugFilter(wsgidav_app, next_app, config)

conf = {
    ...
    "middleware_stack": [
        debug_filter,
        ...
        ],
    ...
    }

If the middleware class constructor has a common signature, it is sufficient to pass the class instead of the instantiated object. The built-in middleware derives from BaseMiddleware, so we can simplify as:

from wsgidav.dir_browser import WsgiDavDirBrowser
from wsgidav.mw.debug_filter import WsgiDavDebugFilter
from wsgidav.error_printer import ErrorPrinter
from wsgidav.http_authenticator import HTTPAuthenticator
from wsgidav.request_resolver import RequestResolver

conf = {
    ...
    "middleware_stack": [
        WsgiDavDebugFilter,
        ErrorPrinter,
        HTTPAuthenticator,
        WsgiDavDirBrowser,
        RequestResolver,  # this must be the last middleware item
        ],
    ...
    }

The middleware stack can be configured and extended. The following example removes the directory browser, and adds a third-party debugging tool:

import dozer

# from wsgidav.dir_browser import WsgiDavDirBrowser
from wsgidav.mw.debug_filter import WsgiDavDebugFilter
from wsgidav.error_printer import ErrorPrinter
from wsgidav.http_authenticator import HTTPAuthenticator
from wsgidav.request_resolver import RequestResolver

# Enable online profiling and GC inspection. See https://github.com/mgedmin/dozer
# (Requires `pip install Dozer`):
dozer_app = dozer.Dozer(wsgidav_app)
dozer_profiler = dozer.Profiler(dozer_app, None, "/tmp")

conf = {
    ...
    "middleware_stack": [
        dozer_app,
        dozer_profiler,
        WsgiDavDebugFilter,
        ErrorPrinter,
        HTTPAuthenticator,
        # WsgiDavDirBrowser,
        RequestResolver,  # this must be the last middleware item
        ],
    ...
    }

The stack can also be defined in text files, for example YAML. Again, we can pass an import path for a WSGI compliant class if the signature is known. For third-party middleware however, the constructor’s positional arguments should be explicitly listed:

...
middleware_stack:
    - class: dozer.Dozer
      args:
        - "${application}"
    - class: dozer.Profiler
      args:
        - "${application}"
        - null  # global_conf
        - /tmp  # profile_path
    - wsgidav.mw.debug_filter.WsgiDavDebugFilter
    - wsgidav.error_printer.ErrorPrinter
    - wsgidav.http_authenticator.HTTPAuthenticator
    - wsgidav.dir_browser.WsgiDavDirBrowser
    - wsgidav.request_resolver.RequestResolver

It is also possible to pass options as named args (i.e. ‘kwargs’):

...
middleware_stack:
    ...
    - class: dozer.Profiler
      kwargs:
        app: "${application}"
        profile_path: /tmp
    ...

Note that the external middleware must be available, for example by calling pip install Doze, so this will not be possible if WsgiDAV is running from the MSI installer.

DAVProvider

A DAVProvider handles read and write requests for all URLs that start with a given share path.

WsgiDAV comes bundled with FilesystemProvider, a DAVProvider that serves DAV requests by reading and writing to the server’s file system.
However, custom DAVProviders may be implemented and used, that publish a database backend, cloud drive, or any virtual data structure.

The provider_mapping configuration routes share paths to specific DAVProvider instances.

By default a writable FilesystemProvider is assumed, but can be forced to read-only. Note that a DomainController may still restrict access completely or prevent editing depending on authentication.

Three syntax variants are supported:

  1. <share_path>: <folder_path>: use FilesystemProvider(folder_path)

  2. <share_path>: { "root": <folder_path>, "readonly": <bool> }: use FilesystemProvider(folder_path, readonly)

  3. <share_path>: { "class": <class_path>, args: [arg, ...], kwargs: {"arg1": val1, "arg2": val2, ... }} Instantiate a custom class (derrived from DAVProvider) using named kwargs.

For example:

provider_mapping:
    "/": "/path/to/share1"
    "/home": "~"
    "/pub":
        root: "/path/to/share2"
        readonly: true
    "/share3":
        class: path.to.CustomDAVProviderClass
        args:
            - pos_arg1
            - pos_arg2
        kwargs:
            path: '/path/to/share3'
            another_arg: 42

Property Manager

The built-in PropertyManager`.

Possible options are:

  • Disable locking, by passing property_manager: null.

  • Enable default storage, which is implemented using a memory-based, not persistent storage, by passing property_manager: true. (This is an alias for property_manager: wsgidav.prop_man.property_manager.PropertyManager)

  • Enable an installed or custom storage

Example: Use a persistent shelve based property storage:

property_manager:
    class: wsgidav.prop_man.property_manager.ShelvePropertyManager
    storage_path: /path/to/wsgidav_locks.shelve

Lock Manager and Storage

The built-in LockManager requires a LockStorageDict instance.

Possible options are:

  • Disable locking, by passing lock_storage: null.

  • Enable default locking, which is implemented using a memory-based, not persistent storage, by passing lock_storage: true. (This is an alias for lock_storage: wsgidav.lock_man.lock_storage.LockStorageDict)

  • Enable an installed lock storage

A persistent, shelve based LockStorageShelve is also available:

lock_storage:
    class: wsgidav.lock_man.lock_storage.LockStorageShelve
    kwargs:
        storage_path: /path/to/wsgidav_locks.shelve

Domain Controller

The HTTP authentication middleware relies on a domain controller. Currently three variants are supported.

SimpleDomainController

The wsgidav.dc.simple_dc.SimpleDomainController allows to authenticate against a plain mapping of shares and user names.

The pseudo-share "*" maps all URLs that are not explicitly listed.

A value of true can be used to enable anonymous access.

Example YAML configuration:

http_authenticator:
    domain_controller: null  # Same as wsgidav.dc.simple_dc.SimpleDomainController
    accept_basic: true  # Pass false to prevent sending clear text passwords
    accept_digest: true
    default_to_digest: true

simple_dc:
    user_mapping:
        "*":
            "user1":
                password: "abc123"
            "user2":
                password: "qwerty"
        "/pub": true

An optional roles list will be passed in environ[“wsgidav.auth.roles”] to downstream middleware. This is currently not used by the provided middleware, but may be handy for custom handlers:

simple_dc:
    user_mapping:
        "*":
            "user1":
                password: "abc123"
                roles: ["editor", "admin"]
            "user2":
                password: "abc123"
                roles: []

If no config file is used, anonymous authentication can be enabled on the command line like:

$ wsgidav ... --auth=anonymous

which simply defines this setting:

simple_dc:
    user_mapping:
        "*": true

NTDomainController

Allows users to authenticate against a Windows NT domain or a local computer.

The wsgidav.dc.nt_dc.NTDomainController requires basic authentication and therefore should use SSL.

Example YAML configuration:

ssl_certificate: wsgidav/server/sample_bogo_server.crt
ssl_private_key: wsgidav/server/sample_bogo_server.key
ssl_certificate_chain: None

http_authenticator:
    domain_controller: wsgidav.dc.nt_dc.NTDomainController
    accept_basic: true
    accept_digest: false
    default_to_digest: false

nt_dc:
    preset_domain: null
    preset_server: null

If no config file is used, NT authentication can be enabled on the command line like:

$ wsgidav ... --auth=nt

PAMDomainController

Allows users to authenticate against a PAM (Pluggable Authentication Modules), that are at the core of user authentication in any modern linux distribution and macOS.

The wsgidav.dc.pam_dc.PAMDomainController requires basic authentication and therefore should use SSL.

Example YAML configuration that authenticates users against the server’s known user accounts:

ssl_certificate: wsgidav/server/sample_bogo_server.crt
ssl_private_key: wsgidav/server/sample_bogo_server.key
ssl_certificate_chain: None

http_authenticator:
    domain_controller: wsgidav.dc.pam_dc.PAMDomainController
    accept_basic: true
    accept_digest: false
    default_to_digest: false

pam_dc:
    service: "login"

If no config file is used, PAM authentication can be enabled on the command line like:

$ wsgidav ... --auth=pam-login

Custom Domain Controllers

A custom domain controller can be used like so:

http_authenticator:
    domain_controller: path.to.CustomDomainController

The constructor must accept two arguments:

def __init__(self, wsgidav_app, config)

Note that this allows the custom controller to read the configuration dict and look for a custom section there.

Cors Middleware

The wsgidav.mw.cors.Cors Respond to CORS preflight OPTIONS request and inject CORS headers. This middleware is available by default, but needs configuration to be enabled. A minimal (yet ):

cors:
    #: List of allowed Origins or '*'
    #: Default: false, i.e. prevent CORS
    # allow_origin: null
    allow_origin: '*'

This may be too unspecific though. See Cross-Origin Resource Sharing (CORS) .

Annotated YAML configuration:

cors:
    #: List of allowed Origins or '*'
    #: Default: false, i.e. prevent CORS
    allow_origin: null
    # allow_origin: '*'
    # allow_origin:
    #   - 'https://example.com'
    #   - 'https://localhost:8081'

    #: List or comma-separated string of allowed methods (returned as
    #: response to preflight request)
    allow_methods:
    # allow_methods: POST,HEAD
    #: List or comma-separated string of allowed header names (returned as
    #: response to preflight request)
    allow_headers:
    #   - X-PINGOTHER
    #: List or comma-separated string of allowed headers that JavaScript in
    #: browsers is allowed to access.
    expose_headers:
    #: Set to true to allow responses on requests with credentials flag set
    allow_credentials: false
    #: Time in seconds for how long the response to the preflight request can
    #: be cached (default: 5)
    max_age: 600
    #: Add custom response headers (dict of header-name -> header-value items)
    #: (This is not related to CORS or required to implement CORS functionality)
    add_always:
    #    'X-Foo-Header: 'qux'

Sample wsgidav.yaml

The YAML syntax is the recommended format to define configuration:

Download Sample Configuration.

  1# WsgiDAV configuration file
  2#
  3# 1. Rename this file to `wsgidav.yaml`.
  4# 2. Adjust settings as appropriate.
  5# 3. Run `wsgidav` from the same directory or pass file path with `--config` option.
  6#
  7# See https://wsgidav.readthedocs.io/en/latest/user_guide_configure.html
  8#
  9# ============================================================================
 10# SERVER OPTIONS
 11
 12#: Run WsgiDAV inside this  WSGI server.
 13#: Supported servers:
 14#:     cheroot, ext-wsgiutils, gevent, gunicorn, paste, uvicorn, wsgiref
 15#: 'wsgiref' and 'ext_wsgiutils' are simple builtin servers that should *not* be
 16#: used in production.
 17#: All other servers must have been installed before, e.g. `pip install cheroot`.
 18#: (The binary MSI distribution already includes 'cheroot'.)
 19#: Default: 'cheroot', use the `--server` command line option to change this.
 20
 21server: cheroot
 22
 23#: Server specific arguments, passed to the server. For example cheroot:
 24#:   https://cheroot.cherrypy.dev/en/latest/pkg/cheroot.wsgi.html#cheroot.wsgi.Server
 25# server_args:
 26#     max: -1
 27#     numthreads: 10
 28#     request_queue_size: 5
 29#     shutdown_timeout: 5
 30#     timeout: 10
 31
 32# Server hostname (default: localhost, use --host on command line)
 33host: 0.0.0.0
 34
 35# Server port (default: 8080, use --port on command line)
 36port: 8080
 37
 38# Transfer block size in bytes
 39block_size: 8192
 40
 41#: Add the MS-Author-Via Response Header to OPTIONS command to allow editing
 42#: with Microsoft Office (default: true)
 43add_header_MS_Author_Via: true
 44
 45hotfixes:
 46    #: Handle Microsoft's Win32LastModifiedTime property.
 47    #: This is useful only in the case when you copy files from a Windows
 48    #: client into a WebDAV share. Windows sends the "last modified" time of
 49    #: the file in a Microsoft extended property called "Win32LastModifiedTime"
 50    #: instead of the standard WebDAV property "getlastmodified". So without
 51    #: this config option set to "True", the "last modified" time of the copied
 52    #: file will be "now" instead of its original value.
 53    #: The proper solution for dealing with the Windows WebDAV client is to use
 54    #: a persistent property manager. This setting is merely a work-around.
 55    #: NOTE: Works with Win10, can't work with Win7. Other versions untested.
 56    emulate_win32_lastmod: false
 57    #: Re-encode PATH_INFO using UTF-8 (falling back to ISO-8859-1).
 58    #: This seems to be wrong, since per PEP 3333 PATH_INFO is always ISO-8859-1
 59    #: encoded (see https://www.python.org/dev/peps/pep-3333/#unicode-issues).
 60    #: However it also seems to resolve errors when accessing resources with
 61    #: Chinese characters, for example (see issue #73).
 62    re_encode_path_info: true
 63    #: Force unquoting of PATH_INFO. This should already be done by the WSGI
 64    #: Framework, so this setting should only be used to fix unexpected problems
 65    #: there (false fixes issue #8, true fixes issue #228).
 66    unquote_path_info: false
 67    #: Hotfix for WinXP / Vista: accept 'OPTIONS /' for a 'OPTIONS *'
 68    #: (default: false)
 69    treat_root_options_as_asterisk: false
 70
 71
 72# ----------------------------------------------------------------------------
 73# SSL Support
 74
 75#: The certificate should match the servers hostname, so the bogus certs will
 76#: not work in all scenarios.
 77#: (Paths can be absolute or relative to this config file.)
 78
 79# ssl_certificate: 'wsgidav/server/sample_bogo_server.crt'
 80# ssl_private_key: 'wsgidav/server/sample_bogo_server.key'
 81# ssl_certificate_chain: null
 82
 83#: Cheroot server supports 'builtin' and 'pyopenssl' (default: 'builtin')
 84# ssl_adapter: 'pyopenssl'
 85
 86# ----------------------------------------------------------------------------
 87
 88#: Modify to customize the WSGI application stack.
 89#: See here for an example how to add custom middlewares:
 90#:   https://wsgidav.readthedocs.io/en/latest/user_guide_configure.html#middleware-stack
 91middleware_stack:
 92    - wsgidav.mw.cors.Cors
 93    # - wsgidav.mw.debug_filter.WsgiDavDebugFilter
 94    - wsgidav.error_printer.ErrorPrinter
 95    - wsgidav.http_authenticator.HTTPAuthenticator
 96    - wsgidav.dir_browser.WsgiDavDirBrowser
 97    - wsgidav.request_resolver.RequestResolver  # this must be the last middleware item
 98
 99# ==============================================================================
100# SHARES
101
102#: Application root, applied before provider mapping shares, e.g. 
103#:   <mount_path>/<share_name>/<res_path>
104#: Set this to the mount point (aka location) when WsgiDAV is running behind a 
105#: reverse proxy.
106#: If set, the mount path must have a leading (but not trailing) slash.
107mount_path: null
108
109#: Route share paths to DAVProvider instances
110#: By default a writable `FilesystemProvider` is assumed, but can be forced
111#: to read-only.
112#: Note that a DomainController may still restrict access completely or prevent
113#: editing depending on authentication.
114#:
115#: The following syntax variants are supported to use FilesystemProvider:
116#:     <share_path>: <folder_path>
117#: or
118#:     <share_path>: { 'root': <folder_path>, 'readonly': <bool> }
119#: or instantiate an arbitrary custom class:
120#:     <share_path>: { 'class': <class_path>, args: [<arg>, ...], kwargs: {<arg>: <val>, ...} }
121
122provider_mapping:
123    '/': '/path/to/share1'
124    '/pub':
125        root: '/path/to/share2'
126        readonly: true
127    '/share3':
128        class: path.to.CustomDAVProviderClass
129        kwargs:
130            path: '/path/to/share3'
131            another_arg: 42
132    # Example: 
133    #     make sure that a `/favicon.ico` URL is resolved, even if a `*.html`
134    #     or `*.txt` resource file was opened using the DirBrowser
135    # '/':
136    #     class: 'wsgidav.fs_dav_provider.FilesystemProvider'
137    #     kwargs:
138    #         root_folder: 'tests/fixtures/share'
139    #         # readonly: true
140    #         shadow:
141    #             '/favicon.ico': 'file_path/to/favicon.ico'
142
143
144# ==============================================================================
145# AUTHENTICATION
146http_authenticator:
147    #: Allow basic authentication
148    accept_basic: true
149    #: Allow digest authentication
150    accept_digest: true
151    #: true (default digest) or false (default basic)
152    default_to_digest: true
153    #: Header field that will be accepted as authorized user.
154    #: Including quotes, for example: trusted_auth_header = 'REMOTE_USER'
155    trusted_auth_header: null
156    #: Domain controller that is used to resolve realms and authorization.
157    #: Default null: which uses SimpleDomainController and the
158    #: `simple_dc.user_mapping` option below.
159    #: (See http://wsgidav.readthedocs.io/en/latest/user_guide_configure.html
160    #: for details.)
161    domain_controller: null
162    # domain_controller: wsgidav.dc.simple_dc.SimpleDomainController
163    # domain_controller: wsgidav.dc.pam_dc.PAMDomainController
164    # domain_controller: wsgidav.dc.nt_dc.NTDomainController
165
166
167# Additional options for SimpleDomainController only:
168simple_dc:
169    # Access control per share.
170    # These routes must match the provider mapping.
171    # NOTE: Provider routes without a matching entry here, are inaccessible.
172    user_mapping:
173        '*':  # default (used for all shares that are not explicitly listed)
174            'user1':
175                password: 'abc123'
176                # Optional: passed to downstream middleware as environ["wsgidav.auth.roles"]
177                roles: ['editor']
178            'user2':
179                password: 'def456'
180                password: 'qwerty'
181        '/pub': true  # Pass true to allow anonymous access
182
183# Additional options for NTDomainController only:
184nt_dc:
185    preset_domain: null
186    preset_server: null
187
188# Additional options for PAMDomainController only:
189pam_dc:
190    service: 'login'
191    encoding: 'utf-8'
192    resetcreds: true
193
194
195# ----------------------------------------------------------------------------
196# CORS
197# (Requires `wsgidav.mw.cors.Cors`, which is enabled by default.)
198cors:
199    #: List of allowed Origins or '*'
200    #: Default: false, i.e. prevent CORS
201    allow_origin: null
202    # allow_origin: '*'
203    # allow_origin:
204    #   - 'https://example.com'
205    #   - 'https://localhost:8081'
206
207    #: List or comma-separated string of allowed methods (returned as
208    #: response to preflight request)
209    allow_methods:
210    # allow_methods: POST,HEAD
211    #: List or comma-separated string of allowed header names (returned as
212    #: response to preflight request)
213    allow_headers:
214    #   - X-PINGOTHER
215    #: List or comma-separated string of allowed headers that JavaScript in
216    #: browsers is allowed to access.
217    expose_headers:
218    #: Set to true to allow responses on requests with credentials flag set
219    allow_credentials: false
220    #: Time in seconds for how long the response to the preflight request can
221    #: be cached (default: 5)
222    max_age: 600
223    #: Add custom response headers (dict of header-name -> header-value items)
224    #: (This is not related to CORS or required to implement CORS functionality)
225    add_always:
226    #    'X-Foo-Header: 'qux'
227
228# ----------------------------------------------------------------------------
229# Property Manager
230# null: (default) no support for dead properties
231# true: Use wsgidav.prop_man.property_manager.PropertyManager
232#       which is an in-memory property manager (NOT persistent)
233#
234# Example: Use persistent shelve based property manager
235#     property_manager:
236#        class: wsgidav.prop_man.property_manager.ShelvePropertyManager
237#        kwargs:
238#            storage_path: 'wsgidav-props.shelve'
239
240property_manager: null
241
242#: Optional additional live property modification
243#: Note: by default live properties like file size and last-modified time are
244#: read-only, but that can be overriden here if the underlying DAV provider
245#: supports it. For now only the FileSystemProvider supports it and only namely
246#: changes to the last-modified timestamp. Enable it with the mutable_live_props
247#: list as below to allow clients to use the utime system call or e.g. the
248#: touch or cp / rsync commands with the preserve-timestamp flags on a mounted
249#: DAV share.
250#: Please note that the timestamp is set on the actual file or directory, so it
251#: is persistent even for in-memory property managers. It should also be noted
252#: that mutable last-modified may not be compliant with the RFC 4918.
253mutable_live_props:
254    # Enable to allow clients to use e.g. the touch or cp / rsync commands with the
255    # preserve-timestamp flags in a mounted DAV share (may be RFC4918 incompliant)
256    - '{DAV:}getlastmodified'
257
258
259# ----------------------------------------------------------------------------
260# Lock Manager Storage
261#
262# null: No lock support
263# true: (default) shortcut for
264#     lock_storage: wsgidav.lock_man.lock_storage.LockStorageDict
265#
266# Note that the default LockStorageDict works in-memory, so it is
267# NOT persistent.
268#
269# Example: Use persistent shelve based lock storage:
270#     lock_storage:
271#         class: wsgidav.lock_man.lock_storage.LockStorageShelve
272#         kwargs:
273#             storage_path: /path/to/wsgidav_locks.shelve
274#
275# Check the documentation on how to develop custom lock storage.
276
277lock_storage: true
278
279
280# ==============================================================================
281# DEBUGGING
282
283#: Set verbosity level (can be overridden by -v or -q arguments)
284verbose: 3
285
286logging:
287    #: Set logging output format
288    #: (see https://docs.python.org/3/library/logging.html#logging.Formatter)
289    logger_date_format: '%H:%M:%S'
290    logger_format: '%(asctime)s.%(msecs)03d - %(levelname)-8s: %(message)s'
291    # Example: Add date,thread id, and logger name:
292    # logger_date_format: '%Y-%m-%d %H:%M:%S'
293    # logger_format: '%(asctime)s.%(msecs)03d - <%(thread)05d> %(name)-27s %(levelname)-8s: %(message)s'
294
295    #: Enable specific module loggers
296    #: E.g. ['lock_manager', 'property_manager', 'http_authenticator', ...]
297    # enable_loggers: ['http_authenticator', ]
298
299    # Enable max. logging for certain http methods
300    # E.g. ['COPY', 'DELETE', 'GET', 'HEAD', 'LOCK', 'MOVE', 'OPTIONS', 'PROPFIND', 'PROPPATCH', 'PUT', 'UNLOCK']
301    debug_methods: []
302
303    # Enable max. logging during  litmus suite tests that contain certain strings
304    # E.g. ['lock_excl', 'notowner_modify', 'fail_cond_put_unlocked', ...]
305    debug_litmus: []
306
307
308# ----------------------------------------------------------------------------
309# WsgiDavDirBrowser
310
311dir_browser:
312    enable: true
313    #: List of fnmatch patterns that will be hidden in the directory listing
314    ignore:
315        - '.DS_Store'  # macOS folder meta data
316        - 'Thumbs.db'  # Windows image previews
317        - '._*'  # macOS hidden data files
318    #: Add a trailing slash to directory URLs (by generating a 301 redirect)
319    directory_slash: true
320    #: Display WsgiDAV icon in header
321    icon: true
322    #: Raw HTML code, appended as footer (true: use a default trailer)
323    response_trailer: true
324    #: Display the name and realm of the authenticated user (or 'anomymous')
325    show_user: true
326    show_logout: true
327    #: Send <dm:mount> response if request URL contains '?davmount'
328    #: (See https://tools.ietf.org/html/rfc4709)
329    davmount: true
330    #: Add a 'Mount' link at the top of the listing
331    davmount_links: false
332    #: Invoke MS Office documents for editing using WebDAV by adding a JavaScript
333    #: click handler.
334    #: - For IE 11 and below invokes the SharePoint ActiveXObject("SharePoint.OpenDocuments")
335    #: - If the custom legacy Firefox plugin is available, it will be used
336    #:   https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ff407576(v%3Doffice.14)
337    #: - Otherwise the Office URL prefix is used (e.g. 'ms-word:ofe|u|http://server/path/file.docx')
338    ms_sharepoint_support: true
339    #: Invoke Libre Office documents for editing using WebDAV
340    libre_office_support: true
341    #: The path to the directory that contains template.html and associated
342    #: assets.
343    #: The default is the htdocs directory within the dir_browser directory.
344    htdocs_path: null

Sample wsgidav.json

We can also use a JSON file for configuration. The structure is identical to the YAML format.

See the ./sample_wsgidav.json example. (Note that the parser allows JavaScript-style comments)

Configuration Tips

Running Behind a Reverse Proxy

If WsgiDAV is running behind a reverse proxy, …

For example, when nginx is used to expose the local WsgiDAV share http://127.0.0.1:8080/public_drive as http://example.com/drive, the configuration files may look like this:

wsgidav.yaml

host: 127.0.0.1
port: 8080
mount_path: "/drive"
provider_mapping:
    "/public_drive":  # Exposed as http://HOST/drive by nginx reverse proxy
        root: "fixtures/share"

nginx.conf:

http {
    ...
    server {
        listen       80;
        server_name  example.com;
        ...
        location /drive/ {
            proxy_pass http://127.0.0.1:8080/public_drive/;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host $host;
        }
        # If dir browser is enabled for WsgiDAV:
        location /drive/:dir_browser/ {
            proxy_pass http://127.0.0.1:8080/:dir_browser/;
        }

See the nginx docs for details.