forked from alexbakker/webdav-provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer.nix
94 lines (84 loc) · 2.08 KB
/
container.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{ config, pkgs, lib, ... }:
let
davPathNginx = "/var/lib/webdav-nginx";
davPathApache = "/var/lib/webdav-apache";
davPathApacheLock = "/var/lib/httpd/dav";
in {
services.nginx = {
enable = true;
package = pkgs.nginx.override {
modules = with pkgs.nginxModules; [ dav ];
};
virtualHosts."_" = {
locations = {
"/" = {
root = davPathNginx;
extraConfig = ''
autoindex on;
client_max_body_size 1g;
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
'';
};
# proxy for Apache WebDAV
"/webdav" = {
extraConfig = ''
set $destination $http_destination;
if ($destination ~* ^https(.+)$) {
set $destination http$1;
}
proxy_pass http://127.0.0.1:8000;
proxy_set_header Destination $destination;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
'';
};
};
};
};
services.httpd = {
enable = true;
adminAddr = "localhost";
extraModules = [
"dav"
"dav_fs"
"dav_lock"
];
extraConfig = ''
DAVLockDB ${davPathApacheLock}/lock
'';
virtualHosts = {
"webdav" = {
listen = [
{
ip = "*";
port = 8000;
}
];
extraConfig = ''
ServerAlias *
DocumentRoot ${davPathApache}
Alias /webdav ${davPathApache}
<Directory ${davPathApache}>
Order allow,deny
Allow from all
Require all granted
Options Indexes
DAV On
</Directory>
'';
};
};
};
systemd.services.nginx = {
serviceConfig = {
ReadWritePaths = davPathNginx;
};
};
systemd.tmpfiles.rules = [
"d ${davPathNginx} 0770 nginx nginx -"
"d ${davPathApache} 0770 wwwrun wwwrun -"
"d ${davPathApacheLock} 0770 wwwrun wwwrun"
];
networking.firewall.allowedTCPPorts = [ 80 8000 ];
}