appsettings.json 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. {
  2. "Sers": {
  3. /* 通讯层配置 */
  4. "CL": {
  5. /* one conn is one channel.can be multiable */
  6. "Client": [
  7. {
  8. // Socket.Iocp
  9. /* (x.1) type - Iocp */
  10. /* the class of builder in assemblyFile */
  11. "className": "Sers.CL.Socket.Iocp.OrganizeClientBuilder",
  12. /* 通信模式(默认值:Simple)。可为 Simple、Timer、ThreadWait */
  13. //"mode": "ThreadWait",
  14. /* (x.2) conn config */
  15. /* 服务端 host地址。例如: "127.0.0.1"、"sers.cloud" */
  16. "host": "127.0.0.1",
  17. /* 服务端 监听端口号。例如: 4501 */
  18. "port": 4501,
  19. "workThread": {
  20. // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
  21. "mode": "LongThread",
  22. /* 后台处理消息的线程个数(单位个,默认2) */
  23. "threadCount": 2,
  24. /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
  25. "maxThreadCount": 100,
  26. /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
  27. "pendingQueueLength": 100000,
  28. /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
  29. "timeoutMs": 300000
  30. },
  31. /* 请求超时时间(单位ms,默认300000) */
  32. "requestTimeoutMs": 300000,
  33. //HeartBeat
  34. /* 心跳检测时间间隔(单位ms,默认10000,若指定为0则不进行心跳检测) */
  35. "heartBeatIntervalMs": 10000,
  36. /* 心跳检测超时时间(单位ms,默认30000) */
  37. "heartBeatTimeoutMs": 30000,
  38. /* 心跳检测失败重试次数(单位次,默认10) */
  39. "heartBeatRetryCount": 10,
  40. /* 连接秘钥,用以验证连接安全性。服务端和客户端必须一致 */
  41. "secretKey": "SersCL"
  42. }
  43. ]
  44. },
  45. // RpcData序列化模式。可不指定。默认为Text。
  46. // 可为 Newtonsoft、Text、BytePointor。
  47. // 效率依次递增。BytePointor 序列化为二进制数据而不是json字符串。
  48. "RpcDataSerializeMode": "Text",
  49. /* ServiceStation配置,可不指定 */
  50. "ServiceStation": {
  51. /* serviceStation站点信息 */
  52. "serviceStationInfo": {
  53. "serviceStationName": "Gateway"
  54. }
  55. },
  56. /* 网关配置 */
  57. "Gateway": {
  58. /* Rpc配置,可不指定 */
  59. "Rpc": {
  60. /* 网关转发的请求中的rpc 信息中的 CallerSource。(暗指调用来源,默认"OutSide") */
  61. //"CallerSource": "OutSide"
  62. },
  63. "WebHost": {
  64. /* url,可多个 */
  65. "urls": [ "http://*:4582" ],
  66. /* ssl证书,可不指定。若urls中指定了https协议,请在此指定对应的https证书 */
  67. "//certificates": [
  68. {
  69. "filePath": "Data/ssl.pfx",
  70. "password": "password"
  71. }
  72. ],
  73. /* 重定向所有的http请求到https。若不指定则不重定向 */
  74. "//httpsRedirection": {
  75. /* 重定向的地址。若不指定,则使用发起请求的host */
  76. "host": "serset.com",
  77. /* 重定向的端口号。若不指定,则使用发起请求的port */
  78. "port": 443,
  79. /* The status code used for the redirect response. The default is 307. */
  80. "statusCode": 307
  81. },
  82. /* 是否允许跨域访问,默认true */
  83. "allowAnyOrigin": true,
  84. /* 把请求的ip地址、端口号复制到请求头中的前缀。若不指定则不复制。 */
  85. "prefixOfCopyIpToHeader": "Sers-Gateway-",
  86. /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset */
  87. "//ResponseDefaultContentType": "application/json; charset=UTF-8",
  88. /* 映射静态文件。若不指定则不映射静态文件 */
  89. "//staticFiles": {
  90. /* 请求路径(可不指定)。demo:"/file/static"。The relative request path that maps to static resources */
  91. //"requestPath": "/file",
  92. /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则为默认路径(wwwroot)。demo:"wwwroot/demo" */
  93. //"rootPath": "wwwroot",
  94. /* 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering may affect performance */
  95. //"defaultFileNames": [],
  96. /* 是否可浏览目录(default false)。Enables directory browsing */
  97. //"useDirectoryBrowser": false,
  98. /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
  99. "contentTypeMapFile": "contentTypeMap.json",
  100. /* 回应静态文件时额外添加的http回应头。可不指定。 */
  101. "responseHeaders": {
  102. //设置浏览器静态文件缓存3600秒
  103. "Cache-Control": "public,max-age=3600"
  104. }
  105. }
  106. },
  107. //调用api前的事件,可不指定
  108. "BeforeCallApi": [
  109. {
  110. /* 在此Assembly中加载类 */
  111. "assemblyFile": "Sers.Core.dll",
  112. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  113. //"className": "Bearer",
  114. //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  115. /* 验证at接口的地址 */
  116. "api_verifyAt": "/AuthCenter/account/verifyAt",
  117. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  118. "api_httpMethod": "POST"
  119. },
  120. {
  121. /* 在此Assembly中加载类 */
  122. "assemblyFile": "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.JsonWebToken.dll",
  123. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  124. //"className": "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.JsonWebToken.JsonWebToken",
  125. //在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),或cookie中的Authorization, 并把jwt中的Claims信息放到 rpcData.user.userInfo
  126. // if token is valid, will set rpcData.caller.source to CallerSource
  127. "CallerSource": "Internal",
  128. //"issuer": "https://sso.lith.cloud:4",
  129. //"audiences": [ "http://localhost:4580" ],
  130. "publicKeysDiscovery_Url": "https://sso.lith.cloud:4/oauth2/v1/discovery/keys"
  131. },
  132. {
  133. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  134. //"className": "AccountInCookie",
  135. "account": [
  136. {
  137. "userToken": "admin_123456",
  138. //"CallerSource": "Internal",
  139. "userInfo": {
  140. "name": "超级管理员",
  141. "入口": "Gover网关"
  142. }
  143. }
  144. ]
  145. }
  146. ],
  147. /* 服务限流配置,可不指定 */
  148. "rateLimit": [
  149. {
  150. /* 服务限流key,标识一个限流服务,必须唯一 */
  151. "rateLimitKey": "rate",
  152. /* 固定时间窗口限流。在单位时间(msInterval)内限制最大请求数量为reqLimit。超出数量的请求将被拒绝 */
  153. "rateLimitType": "FixedWindow",
  154. /* 单位时间内最大请求数量(个)*/
  155. "reqLimit": 100000,
  156. /* 单位时间长度(单位:ms)*/
  157. "msInterval": 1000
  158. }
  159. ]
  160. }
  161. },
  162. /* Vit工具配置,可不指定 */
  163. "Vit": {
  164. /* 日志配置,可不指定 */
  165. "Logger": {
  166. /* print the log to Log/*.txt default:true */
  167. "PrintToTxt": true,
  168. /* print the log to console. default:true */
  169. "PrintToConsole": true
  170. },
  171. /* 序列化配置,可不指定 */
  172. "Serialization": {
  173. /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
  174. "Encoding": "UTF8",
  175. /* 时间序列化格式。可不指定,默认 "yyyy-MM-dd HH:mm:ss" */
  176. "DateTimeFormat": "yyyy-MM-dd HH:mm:ss"
  177. },
  178. "//Kestrel": {
  179. /* (int64) the maximum allowed size of any request body in bytes. When set to null, the maximum request body size is unlimited. */
  180. "MaxRequestBodySize": 2000000000,
  181. /* (int32) A limit on the length of individual form values. Forms containing values that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
  182. "ValueLengthLimit": 2000000000,
  183. /* (int64) A limit for the length of each multipart body. Forms sections that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
  184. "MultipartBodyLengthLimit": 2000000000
  185. }
  186. },
  187. /* 若不指定,则不输出aspnet日志到控制台输出 */
  188. "Logging": {
  189. "LogLevel": {
  190. "Default": "Warning"
  191. }
  192. }
  193. }