diff options
Diffstat (limited to 'template2/nginx/server.ts')
-rw-r--r-- | template2/nginx/server.ts | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/template2/nginx/server.ts b/template2/nginx/server.ts new file mode 100644 index 0000000..ffd64b7 --- /dev/null +++ b/template2/nginx/server.ts @@ -0,0 +1,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[]; +} |