123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- import {FormColumnType} from "planning-tools";
- import {NgxModuleData} from "../pages/nginx/components/input.ts";
- export type INginx = {
- id: number
- name: string
- uid: string
- /**
- * 数据目录,所有自定义配置文件都在里面
- * conf.d stream.d backup certs
- */
- dataDir: string
- /**
- * nginx的配置文件主目录,及nginx.conf 配置文件所在的目录
- */
- nginxDir: string
- /**
- * nginx可执行文件
- */
- nginxPath?:string
- isLocal: boolean
- ipAddr: string
- port: number
- user: string
- password: string
- httpData: string
- httpConf: string
- remark: string
- /**
- * 版本信息
- */
- versionInfo?: string
- }
- /**
- * 虚拟主机或者 TCP/UDP代理
- */
- export type INginxServer = {
- /**
- * 唯一标识
- */
- id: number
- /**
- * 是否是负载均衡
- */
- isUpstream?: boolean
- /**
- * 是否为TCP/UDP代理
- */
- isStream?: boolean
- nginxId: number
- enable?: boolean
- http2?: boolean
- /**
- * 配置文件,当前的配置文件
- */
- confData?: string
- server_name: string
- listen: number
- ssl?: boolean
- charset?: string
- access_log?: string
- error_log?: string
- /**
- * 客户端最大的请求体大小,500m 1g
- */
- client_max_body_size?: string
- /**
- * 证书名称,平台托管的证书名称
- */
- certName?: string
- ssl_certificate?: string
- ssl_certificate_key?: string
- /**
- * eg. 5m 1h
- */
- ssl_session_timeout?: string
- // ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4
- ssl_ciphers?: string
- // TLSv1 TLSv1.1 TLSv1.2
- ssl_protocols?: string[]
- ssl_prefer_server_ciphers?: 'on'|'off'
- locations?: INginxLocation[]
- upstreams?: IUpstream[]
- streams?: INginxStream[]
- rewrite?: IRewrite
- remark?: string
- proxy_settings?: NgxModuleData
- tmp_custom_config?: string
- gzip?: NgxModuleData
- }
- /**
- * 负载均衡,跟虚拟主机放在一起吧,方便
- */
- export type IUpstream = {
- name: string
- /**
- * weight\backup 不能和 ip_hash 关键字一起使用。
- * ip_hash 或者weight 轮训
- */
- type?:'ip_hash' | 'weight'
- /**
- * 是否启用
- */
- enable?: boolean
- servers: {
- host: string
- port: number
- weight?: number
- /**
- * down:表示当前的server暂时不参与负载
- * weight:默认为1.weight越大,负载的权重就越大。
- * backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。
- */
- status?: 'down' | 'backup' | 'normal'
- /**
- * 最大失败次数,也就是最多进行 3 次尝试,默认为1
- */
- max_fails?: number
- /**
- * 超时时间,单位秒,默认值是10s
- */
- fail_timeout?: number
- }[]
- }
- export type INginxStream = {
- /**
- * 唯一索引
- */
- key: string
- listen: number
- /**
- * 与被代理服务器建立连接的超时时间为5s
- */
- proxy_connect_timeout?: number
- /**
- * 获取被代理服务器的响应最大超时时间为10s
- */
- proxy_timeout?: number
- /**
- * 当被代理的服务器返回错误或超时时,将未返回响应的客户端连接请求传递给upstream中的下一个服务器
- */
- proxy_next_upstream?: boolean
- /**
- * 总尝试超时时间为10s
- */
- proxy_next_upstream_tries?: number
- /**
- * 总尝试超时时间为10s
- */
- proxy_next_upstream_timeout?: number
- /**
- * 开启SO_KEEPALIVE选项进行心跳检测
- */
- proxy_socket_keepalive?: boolean
- /**
- * proxy_pass
- */
- proxy_pass: string
- /**
- * 是否启用
- */
- enable?: boolean
- }
- export type PNginxServer = Partial<INginxServer>
- /**
- * 键值对
- */
- export type KeyValue = {
- name: string
- value: string
- }
- /**
- * nginx 的location配置
- */
- export type INginxLocation = Omit<NgxModuleData, "data"> & {
- /**
- * 唯一标识
- */
- id: string
- /**
- * location的名称
- */
- name: string;
- /**
- * 匹配规则
- */
- match: {
- path: string
- regex?: string
- }
- index?: string
- root?: string
- alias?: string
- proxy_set_header?: IProxyHeader[]
- add_header?: IProxyHeader[]
- proxy_pass?: string
- // http_502 http_504 http_404 error timeout invalid_header
- proxy_next_upstream?: string[]
- //eg. 60s 1m
- proxy_connect_timeout?: string
- // 1.1
- proxy_http_version?: string
- rewrite?: IRewrite
- proxy_settings?: NgxModuleData
- gzip?: NgxModuleData
- tmp_custom_config?: string
- proxy_type?: 'proxy'| 'static' | 'returnBody' | 'other'
- /**
- * 是否为内部路由
- */
- internal?: boolean
- return?: {
- code: number
- content: string
- }
- /**
- * 临时数据,表示
- */
- __index__?: number
- __deploy__?: any
- }
- export type PLocation = Partial<INginxLocation>
- export type IProxyHeader = {
- name: string
- value: string
- }
- export type IRewrite = {
- /**
- * 正则表达式
- */
- regex: string
- /**
- * 跳转后的内容
- */
- replacement: string
- /**
- * rewrite支持的flag标记
- */
- flag: 'last' | 'break' | 'redirect' | 'permanent'
- }
- /**
- * nginx的自动化表单配置
- */
- export type INginxFormConfig = {
- server: FormColumnType[]
- location: FormColumnType[]
- addNginx: FormColumnType[]
- nginxSettings: FormColumnType[]
- nginxConf: FormColumnType[]
- /**
- * 负载均衡的
- */
- upstream: FormColumnType[]
- stream: FormColumnType[]
- }
- /**
- * 给定的初始值模板
- */
- export type INginxFormTemplate = {
- server: Partial<INginxServer>,
- location: any,
- addNginx: any,
- nginxSettings: any,
- nginxConf: any
- }
|