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
|
// Used to generate json schema.
// path should start with "/", end without "/" and contain no special characters in regex.
// the special case is root path "/", which is allowed.
// For example:
// Given
// path: /a/b
// to: http://c.com/d
// Then (no_strip_prefix is false)
// url: /a/b/c
// redirect to: http://c.com/d/c (/a/b is removed)
// Note:
// Contrary to reverse proxy, you would always want to strip the prefix path.
// Because there is no meaning to redirect to the new page with the original path.
// If you want a domain-only redirect, just specify the path as "/".
export interface RedirectService {
type: "redirect";
path: string; // must be a path, should start with "/", end without "/"
to: string; // must be a url, should start with scheme (http:// or https://), end without "/"
code?: number; // default to 307
}
// For example:
// Given
// path: /a/b
// root: /e/f
// Then (no_strip_prefix is false)
// url: /a/b/c/d
// file path: /e/f/c/d (/a/b is removed)
// Or (no_strip_prefix is true)
// url: /a/b/c/d
// file path: /e/f/a/b/c/d
export interface StaticFileService {
type: "static-file";
path: string; // must be a path, should start with "/", end without "/"
root: string; // must be a path (directory), should start with "/", end without "/"
no_strip_prefix?: boolean; // default to false. If true, the path prefix is not removed from the url when finding the file.
}
// For example:
// Given
// path: /a/b
// upstream: another-server:1234
// Then
// url: /a/b/c/d
// proxy to: another-server:1234/a/b/c/d
// Note:
// Contrary to redirect, you would always want to keep the prefix path.
// Because the upstream server will mess up the path handling if the prefix is not kept.
export interface ReverseProxyService {
type: "reverse-proxy";
path: string; // must be a path, should start with "/", end without "/"
upstream: string; // should be a [host]:[port], like "localhost:1234"
}
export type Service = RedirectService | StaticFileService | ReverseProxyService;
export interface SubDomain {
name: string; // @ for root domain
services: Service[];
}
export interface Server {
domains: SubDomain[];
}
|