Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 20:30 UTC
chore: Clean up adapt test line endings (#4660)
Lots of the files were using CRLF instead of LF. Mostly my fault cause sometimes I make the files on Windows and VSCode for some reason kept making them with the wrong line endings. Sigh. Since .txt files typically default to spaces for indentation, I'm also adding an .editorconfig to ensure they use tabs instead
Francis Lavoie committed
Mar 25, 2022 at 00:48 UTC
4b75f3e2f09b77b98783ea4d6602391c7283f984
7 files changed
+546
-541
.editorconfig
new
+5
@@ -0,0 +1,5 @@
1
+[*]
2
+end_of_line = lf
3
+
4
+[caddytest/integration/caddyfile_adapt/*.txt]
5
+indent_style = tab
\ No newline at end of file
caddytest/integration/caddyfile_adapt/file_server_pass_thru.txt
+32
-32
@@ -1,32 +1,32 @@
1
-:80
2
-
3
-file_server {
4
- pass_thru
5
-}
6
-----------
7
-{
8
- "apps": {
9
- "http": {
10
- "servers": {
11
- "srv0": {
12
- "listen": [
13
- ":80"
14
- ],
15
- "routes": [
16
- {
17
- "handle": [
18
- {
19
- "handler": "file_server",
20
- "hide": [
21
- "./Caddyfile"
22
- ],
23
- "pass_thru": true
24
- }
25
- ]
26
- }
27
- ]
28
- }
29
- }
30
- }
31
- }
32
-}
1
+:80
2
+
3
+file_server {
4
+ pass_thru
5
+}
6
+----------
7
+{
8
+ "apps": {
9
+ "http": {
10
+ "servers": {
11
+ "srv0": {
12
+ "listen": [
13
+ ":80"
14
+ ],
15
+ "routes": [
16
+ {
17
+ "handle": [
18
+ {
19
+ "handler": "file_server",
20
+ "hide": [
21
+ "./Caddyfile"
22
+ ],
23
+ "pass_thru": true
24
+ }
25
+ ]
26
+ }
27
+ ]
28
+ }
29
+ }
30
+ }
31
+ }
32
+}
caddytest/integration/caddyfile_adapt/php_fastcgi_handle_response.txt
+144
-144
@@ -1,145 +1,145 @@
1
-:8881 {
2
- php_fastcgi app:9000 {
3
- env FOO bar
4
-
5
- @error status 4xx
6
- handle_response @error {
7
- root * /errors
8
- rewrite * /{http.reverse_proxy.status_code}.html
9
- file_server
10
- }
11
- }
12
-}
13
-----------
14
-{
15
- "apps": {
16
- "http": {
17
- "servers": {
18
- "srv0": {
19
- "listen": [
20
- ":8881"
21
- ],
22
- "routes": [
23
- {
24
- "match": [
25
- {
26
- "file": {
27
- "try_files": [
28
- "{http.request.uri.path}/index.php"
29
- ]
30
- },
31
- "not": [
32
- {
33
- "path": [
34
- "*/"
35
- ]
36
- }
37
- ]
38
- }
39
- ],
40
- "handle": [
41
- {
42
- "handler": "static_response",
43
- "headers": {
44
- "Location": [
45
- "{http.request.uri.path}/"
46
- ]
47
- },
48
- "status_code": 308
49
- }
50
- ]
51
- },
52
- {
53
- "match": [
54
- {
55
- "file": {
56
- "try_files": [
57
- "{http.request.uri.path}",
58
- "{http.request.uri.path}/index.php",
59
- "index.php"
60
- ],
61
- "split_path": [
62
- ".php"
63
- ]
64
- }
65
- }
66
- ],
67
- "handle": [
68
- {
69
- "handler": "rewrite",
70
- "uri": "{http.matchers.file.relative}"
71
- }
72
- ]
73
- },
74
- {
75
- "match": [
76
- {
77
- "path": [
78
- "*.php"
79
- ]
80
- }
81
- ],
82
- "handle": [
83
- {
84
- "handle_response": [
85
- {
86
- "match": {
87
- "status_code": [
88
- 4
89
- ]
90
- },
91
- "routes": [
92
- {
93
- "handle": [
94
- {
95
- "handler": "vars",
96
- "root": "/errors"
97
- }
98
- ]
99
- },
100
- {
101
- "group": "group0",
102
- "handle": [
103
- {
104
- "handler": "rewrite",
105
- "uri": "/{http.reverse_proxy.status_code}.html"
106
- }
107
- ]
108
- },
109
- {
110
- "handle": [
111
- {
112
- "handler": "file_server",
113
- "hide": [
114
- "./Caddyfile"
115
- ]
116
- }
117
- ]
118
- }
119
- ]
120
- }
121
- ],
122
- "handler": "reverse_proxy",
123
- "transport": {
124
- "env": {
125
- "FOO": "bar"
126
- },
127
- "protocol": "fastcgi",
128
- "split_path": [
129
- ".php"
130
- ]
131
- },
132
- "upstreams": [
133
- {
134
- "dial": "app:9000"
135
- }
136
- ]
137
- }
138
- ]
139
- }
140
- ]
141
- }
142
- }
143
- }
144
- }
1
+:8881 {
2
+ php_fastcgi app:9000 {
3
+ env FOO bar
4
+
5
+ @error status 4xx
6
+ handle_response @error {
7
+ root * /errors
8
+ rewrite * /{http.reverse_proxy.status_code}.html
9
+ file_server
10
+ }
11
+ }
12
+}
13
+----------
14
+{
15
+ "apps": {
16
+ "http": {
17
+ "servers": {
18
+ "srv0": {
19
+ "listen": [
20
+ ":8881"
21
+ ],
22
+ "routes": [
23
+ {
24
+ "match": [
25
+ {
26
+ "file": {
27
+ "try_files": [
28
+ "{http.request.uri.path}/index.php"
29
+ ]
30
+ },
31
+ "not": [
32
+ {
33
+ "path": [
34
+ "*/"
35
+ ]
36
+ }
37
+ ]
38
+ }
39
+ ],
40
+ "handle": [
41
+ {
42
+ "handler": "static_response",
43
+ "headers": {
44
+ "Location": [
45
+ "{http.request.uri.path}/"
46
+ ]
47
+ },
48
+ "status_code": 308
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ "match": [
54
+ {
55
+ "file": {
56
+ "try_files": [
57
+ "{http.request.uri.path}",
58
+ "{http.request.uri.path}/index.php",
59
+ "index.php"
60
+ ],
61
+ "split_path": [
62
+ ".php"
63
+ ]
64
+ }
65
+ }
66
+ ],
67
+ "handle": [
68
+ {
69
+ "handler": "rewrite",
70
+ "uri": "{http.matchers.file.relative}"
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ "match": [
76
+ {
77
+ "path": [
78
+ "*.php"
79
+ ]
80
+ }
81
+ ],
82
+ "handle": [
83
+ {
84
+ "handle_response": [
85
+ {
86
+ "match": {
87
+ "status_code": [
88
+ 4
89
+ ]
90
+ },
91
+ "routes": [
92
+ {
93
+ "handle": [
94
+ {
95
+ "handler": "vars",
96
+ "root": "/errors"
97
+ }
98
+ ]
99
+ },
100
+ {
101
+ "group": "group0",
102
+ "handle": [
103
+ {
104
+ "handler": "rewrite",
105
+ "uri": "/{http.reverse_proxy.status_code}.html"
106
+ }
107
+ ]
108
+ },
109
+ {
110
+ "handle": [
111
+ {
112
+ "handler": "file_server",
113
+ "hide": [
114
+ "./Caddyfile"
115
+ ]
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ }
121
+ ],
122
+ "handler": "reverse_proxy",
123
+ "transport": {
124
+ "env": {
125
+ "FOO": "bar"
126
+ },
127
+ "protocol": "fastcgi",
128
+ "split_path": [
129
+ ".php"
130
+ ]
131
+ },
132
+ "upstreams": [
133
+ {
134
+ "dial": "app:9000"
135
+ }
136
+ ]
137
+ }
138
+ ]
139
+ }
140
+ ]
141
+ }
142
+ }
143
+ }
144
+ }
145
}
\ No newline at end of file
caddytest/integration/caddyfile_adapt/php_fastcgi_try_files_override.txt
+124
-124
@@ -1,124 +1,124 @@
1
-:8884
2
-
3
-php_fastcgi localhost:9000 {
4
- # some php_fastcgi-specific subdirectives
5
- split .php .php5
6
- env VAR1 value1
7
- env VAR2 value2
8
- root /var/www
9
- try_files {path} {path}/index.php =404
10
- dial_timeout 3s
11
- read_timeout 10s
12
- write_timeout 20s
13
-
14
- # passed through to reverse_proxy (directive order doesn't matter!)
15
- lb_policy random
16
-}
17
-----------
18
-{
19
- "apps": {
20
- "http": {
21
- "servers": {
22
- "srv0": {
23
- "listen": [
24
- ":8884"
25
- ],
26
- "routes": [
27
- {
28
- "match": [
29
- {
30
- "file": {
31
- "try_files": [
32
- "{http.request.uri.path}/index.php"
33
- ]
34
- },
35
- "not": [
36
- {
37
- "path": [
38
- "*/"
39
- ]
40
- }
41
- ]
42
- }
43
- ],
44
- "handle": [
45
- {
46
- "handler": "static_response",
47
- "headers": {
48
- "Location": [
49
- "{http.request.uri.path}/"
50
- ]
51
- },
52
- "status_code": 308
53
- }
54
- ]
55
- },
56
- {
57
- "match": [
58
- {
59
- "file": {
60
- "try_files": [
61
- "{http.request.uri.path}",
62
- "{http.request.uri.path}/index.php",
63
- "=404"
64
- ],
65
- "split_path": [
66
- ".php",
67
- ".php5"
68
- ]
69
- }
70
- }
71
- ],
72
- "handle": [
73
- {
74
- "handler": "rewrite",
75
- "uri": "{http.matchers.file.relative}"
76
- }
77
- ]
78
- },
79
- {
80
- "match": [
81
- {
82
- "path": [
83
- "*.php",
84
- "*.php5"
85
- ]
86
- }
87
- ],
88
- "handle": [
89
- {
90
- "handler": "reverse_proxy",
91
- "load_balancing": {
92
- "selection_policy": {
93
- "policy": "random"
94
- }
95
- },
96
- "transport": {
97
- "dial_timeout": 3000000000,
98
- "env": {
99
- "VAR1": "value1",
100
- "VAR2": "value2"
101
- },
102
- "protocol": "fastcgi",
103
- "read_timeout": 10000000000,
104
- "root": "/var/www",
105
- "split_path": [
106
- ".php",
107
- ".php5"
108
- ],
109
- "write_timeout": 20000000000
110
- },
111
- "upstreams": [
112
- {
113
- "dial": "localhost:9000"
114
- }
115
- ]
116
- }
117
- ]
118
- }
119
- ]
120
- }
121
- }
122
- }
123
- }
124
-}
1
+:8884
2
+
3
+php_fastcgi localhost:9000 {
4
+ # some php_fastcgi-specific subdirectives
5
+ split .php .php5
6
+ env VAR1 value1
7
+ env VAR2 value2
8
+ root /var/www
9
+ try_files {path} {path}/index.php =404
10
+ dial_timeout 3s
11
+ read_timeout 10s
12
+ write_timeout 20s
13
+
14
+ # passed through to reverse_proxy (directive order doesn't matter!)
15
+ lb_policy random
16
+}
17
+----------
18
+{
19
+ "apps": {
20
+ "http": {
21
+ "servers": {
22
+ "srv0": {
23
+ "listen": [
24
+ ":8884"
25
+ ],
26
+ "routes": [
27
+ {
28
+ "match": [
29
+ {
30
+ "file": {
31
+ "try_files": [
32
+ "{http.request.uri.path}/index.php"
33
+ ]
34
+ },
35
+ "not": [
36
+ {
37
+ "path": [
38
+ "*/"
39
+ ]
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "handle": [
45
+ {
46
+ "handler": "static_response",
47
+ "headers": {
48
+ "Location": [
49
+ "{http.request.uri.path}/"
50
+ ]
51
+ },
52
+ "status_code": 308
53
+ }
54
+ ]
55
+ },
56
+ {
57
+ "match": [
58
+ {
59
+ "file": {
60
+ "try_files": [
61
+ "{http.request.uri.path}",
62
+ "{http.request.uri.path}/index.php",
63
+ "=404"
64
+ ],
65
+ "split_path": [
66
+ ".php",
67
+ ".php5"
68
+ ]
69
+ }
70
+ }
71
+ ],
72
+ "handle": [
73
+ {
74
+ "handler": "rewrite",
75
+ "uri": "{http.matchers.file.relative}"
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ "match": [
81
+ {
82
+ "path": [
83
+ "*.php",
84
+ "*.php5"
85
+ ]
86
+ }
87
+ ],
88
+ "handle": [
89
+ {
90
+ "handler": "reverse_proxy",
91
+ "load_balancing": {
92
+ "selection_policy": {
93
+ "policy": "random"
94
+ }
95
+ },
96
+ "transport": {
97
+ "dial_timeout": 3000000000,
98
+ "env": {
99
+ "VAR1": "value1",
100
+ "VAR2": "value2"
101
+ },
102
+ "protocol": "fastcgi",
103
+ "read_timeout": 10000000000,
104
+ "root": "/var/www",
105
+ "split_path": [
106
+ ".php",
107
+ ".php5"
108
+ ],
109
+ "write_timeout": 20000000000
110
+ },
111
+ "upstreams": [
112
+ {
113
+ "dial": "localhost:9000"
114
+ }
115
+ ]
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ }
121
+ }
122
+ }
123
+ }
124
+}
caddytest/integration/caddyfile_adapt/reverse_proxy_trusted_proxies.txt
+56
-56
@@ -1,56 +1,56 @@
1
-:8884
2
-
3
-reverse_proxy 127.0.0.1:65535 {
4
- trusted_proxies 127.0.0.1
5
-}
6
-
7
-reverse_proxy 127.0.0.1:65535 {
8
- trusted_proxies private_ranges
9
-}
10
-----------
11
-{
12
- "apps": {
13
- "http": {
14
- "servers": {
15
- "srv0": {
16
- "listen": [
17
- ":8884"
18
- ],
19
- "routes": [
20
- {
21
- "handle": [
22
- {
23
- "handler": "reverse_proxy",
24
- "trusted_proxies": [
25
- "127.0.0.1"
26
- ],
27
- "upstreams": [
28
- {
29
- "dial": "127.0.0.1:65535"
30
- }
31
- ]
32
- },
33
- {
34
- "handler": "reverse_proxy",
35
- "trusted_proxies": [
36
- "192.168.0.0/16",
37
- "172.16.0.0/12",
38
- "10.0.0.0/8",
39
- "127.0.0.1/8",
40
- "fd00::/8",
41
- "::1"
42
- ],
43
- "upstreams": [
44
- {
45
- "dial": "127.0.0.1:65535"
46
- }
47
- ]
48
- }
49
- ]
50
- }
51
- ]
52
- }
53
- }
54
- }
55
- }
56
-}
1
+:8884
2
+
3
+reverse_proxy 127.0.0.1:65535 {
4
+ trusted_proxies 127.0.0.1
5
+}
6
+
7
+reverse_proxy 127.0.0.1:65535 {
8
+ trusted_proxies private_ranges
9
+}
10
+----------
11
+{
12
+ "apps": {
13
+ "http": {
14
+ "servers": {
15
+ "srv0": {
16
+ "listen": [
17
+ ":8884"
18
+ ],
19
+ "routes": [
20
+ {
21
+ "handle": [
22
+ {
23
+ "handler": "reverse_proxy",
24
+ "trusted_proxies": [
25
+ "127.0.0.1"
26
+ ],
27
+ "upstreams": [
28
+ {
29
+ "dial": "127.0.0.1:65535"
30
+ }
31
+ ]
32
+ },
33
+ {
34
+ "handler": "reverse_proxy",
35
+ "trusted_proxies": [
36
+ "192.168.0.0/16",
37
+ "172.16.0.0/12",
38
+ "10.0.0.0/8",
39
+ "127.0.0.1/8",
40
+ "fd00::/8",
41
+ "::1"
42
+ ],
43
+ "upstreams": [
44
+ {
45
+ "dial": "127.0.0.1:65535"
46
+ }
47
+ ]
48
+ }
49
+ ]
50
+ }
51
+ ]
52
+ }
53
+ }
54
+ }
55
+ }
56
+}
caddytest/integration/caddyfile_adapt/sort_directives_within_handle.txt
+132
-132
@@ -1,133 +1,133 @@
1
-*.example.com {
2
- @foo host foo.example.com
3
- handle @foo {
4
- handle_path /strip* {
5
- respond "this should be first"
6
- }
7
- handle {
8
- respond "this should be second"
9
- }
10
- }
11
- handle {
12
- respond "this should be last"
13
- }
14
-}
15
-----------
16
-{
17
- "apps": {
18
- "http": {
19
- "servers": {
20
- "srv0": {
21
- "listen": [
22
- ":443"
23
- ],
24
- "routes": [
25
- {
26
- "match": [
27
- {
28
- "host": [
29
- "*.example.com"
30
- ]
31
- }
32
- ],
33
- "handle": [
34
- {
35
- "handler": "subroute",
36
- "routes": [
37
- {
38
- "group": "group5",
39
- "handle": [
40
- {
41
- "handler": "subroute",
42
- "routes": [
43
- {
44
- "group": "group2",
45
- "handle": [
46
- {
47
- "handler": "subroute",
48
- "routes": [
49
- {
50
- "handle": [
51
- {
52
- "handler": "rewrite",
53
- "strip_path_prefix": "/strip"
54
- }
55
- ]
56
- },
57
- {
58
- "handle": [
59
- {
60
- "body": "this should be first",
61
- "handler": "static_response"
62
- }
63
- ]
64
- }
65
- ]
66
- }
67
- ],
68
- "match": [
69
- {
70
- "path": [
71
- "/strip*"
72
- ]
73
- }
74
- ]
75
- },
76
- {
77
- "group": "group2",
78
- "handle": [
79
- {
80
- "handler": "subroute",
81
- "routes": [
82
- {
83
- "handle": [
84
- {
85
- "body": "this should be second",
86
- "handler": "static_response"
87
- }
88
- ]
89
- }
90
- ]
91
- }
92
- ]
93
- }
94
- ]
95
- }
96
- ],
97
- "match": [
98
- {
99
- "host": [
100
- "foo.example.com"
101
- ]
102
- }
103
- ]
104
- },
105
- {
106
- "group": "group5",
107
- "handle": [
108
- {
109
- "handler": "subroute",
110
- "routes": [
111
- {
112
- "handle": [
113
- {
114
- "body": "this should be last",
115
- "handler": "static_response"
116
- }
117
- ]
118
- }
119
- ]
120
- }
121
- ]
122
- }
123
- ]
124
- }
125
- ],
126
- "terminal": true
127
- }
128
- ]
129
- }
130
- }
131
- }
132
- }
1
+*.example.com {
2
+ @foo host foo.example.com
3
+ handle @foo {
4
+ handle_path /strip* {
5
+ respond "this should be first"
6
+ }
7
+ handle {
8
+ respond "this should be second"
9
+ }
10
+ }
11
+ handle {
12
+ respond "this should be last"
13
+ }
14
+}
15
+----------
16
+{
17
+ "apps": {
18
+ "http": {
19
+ "servers": {
20
+ "srv0": {
21
+ "listen": [
22
+ ":443"
23
+ ],
24
+ "routes": [
25
+ {
26
+ "match": [
27
+ {
28
+ "host": [
29
+ "*.example.com"
30
+ ]
31
+ }
32
+ ],
33
+ "handle": [
34
+ {
35
+ "handler": "subroute",
36
+ "routes": [
37
+ {
38
+ "group": "group5",
39
+ "handle": [
40
+ {
41
+ "handler": "subroute",
42
+ "routes": [
43
+ {
44
+ "group": "group2",
45
+ "handle": [
46
+ {
47
+ "handler": "subroute",
48
+ "routes": [
49
+ {
50
+ "handle": [
51
+ {
52
+ "handler": "rewrite",
53
+ "strip_path_prefix": "/strip"
54
+ }
55
+ ]
56
+ },
57
+ {
58
+ "handle": [
59
+ {
60
+ "body": "this should be first",
61
+ "handler": "static_response"
62
+ }
63
+ ]
64
+ }
65
+ ]
66
+ }
67
+ ],
68
+ "match": [
69
+ {
70
+ "path": [
71
+ "/strip*"
72
+ ]
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ "group": "group2",
78
+ "handle": [
79
+ {
80
+ "handler": "subroute",
81
+ "routes": [
82
+ {
83
+ "handle": [
84
+ {
85
+ "body": "this should be second",
86
+ "handler": "static_response"
87
+ }
88
+ ]
89
+ }
90
+ ]
91
+ }
92
+ ]
93
+ }
94
+ ]
95
+ }
96
+ ],
97
+ "match": [
98
+ {
99
+ "host": [
100
+ "foo.example.com"
101
+ ]
102
+ }
103
+ ]
104
+ },
105
+ {
106
+ "group": "group5",
107
+ "handle": [
108
+ {
109
+ "handler": "subroute",
110
+ "routes": [
111
+ {
112
+ "handle": [
113
+ {
114
+ "body": "this should be last",
115
+ "handler": "static_response"
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ }
121
+ ]
122
+ }
123
+ ]
124
+ }
125
+ ],
126
+ "terminal": true
127
+ }
128
+ ]
129
+ }
130
+ }
131
+ }
132
+ }
133
}
\ No newline at end of file
caddytest/integration/caddyfile_adapt/tls_internal_options.txt
+53
-53
@@ -1,54 +1,54 @@
1
-a.example.com {
2
- tls {
3
- issuer internal {
4
- ca foo
5
- lifetime 24h
6
- sign_with_root
7
- }
8
- }
9
-}
10
-----------
11
-{
12
- "apps": {
13
- "http": {
14
- "servers": {
15
- "srv0": {
16
- "listen": [
17
- ":443"
18
- ],
19
- "routes": [
20
- {
21
- "match": [
22
- {
23
- "host": [
24
- "a.example.com"
25
- ]
26
- }
27
- ],
28
- "terminal": true
29
- }
30
- ]
31
- }
32
- }
33
- },
34
- "tls": {
35
- "automation": {
36
- "policies": [
37
- {
38
- "subjects": [
39
- "a.example.com"
40
- ],
41
- "issuers": [
42
- {
43
- "ca": "foo",
44
- "lifetime": 86400000000000,
45
- "module": "internal",
46
- "sign_with_root": true
47
- }
48
- ]
49
- }
50
- ]
51
- }
52
- }
53
- }
1
+a.example.com {
2
+ tls {
3
+ issuer internal {
4
+ ca foo
5
+ lifetime 24h
6
+ sign_with_root
7
+ }
8
+ }
9
+}
10
+----------
11
+{
12
+ "apps": {
13
+ "http": {
14
+ "servers": {
15
+ "srv0": {
16
+ "listen": [
17
+ ":443"
18
+ ],
19
+ "routes": [
20
+ {
21
+ "match": [
22
+ {
23
+ "host": [
24
+ "a.example.com"
25
+ ]
26
+ }
27
+ ],
28
+ "terminal": true
29
+ }
30
+ ]
31
+ }
32
+ }
33
+ },
34
+ "tls": {
35
+ "automation": {
36
+ "policies": [
37
+ {
38
+ "subjects": [
39
+ "a.example.com"
40
+ ],
41
+ "issuers": [
42
+ {
43
+ "ca": "foo",
44
+ "lifetime": 86400000000000,
45
+ "module": "internal",
46
+ "sign_with_root": true
47
+ }
48
+ ]
49
+ }
50
+ ]
51
+ }
52
+ }
53
+ }
54
}
\ No newline at end of file