Skip to main content
Version: 2.4.1

Gateway Property Config

This paper mainly explains how to configure Apache ShenYu properties on the gateway side.

Property Config#

netty:  tcp:    select:      count: 1    worker:      count: 4    connect_timeout_millis: 10000    write_buffer_high_water_mark: 65536    write_buffer_low_water_mark: 32768    so_keepalive: false    so_reuseaddr: false    so_linger: -1    so_backlog: 128    tcp_nodelay: trueshenyu:#  httpclient:#    strategy: webClient#    connectTimeout: 45000#    readTimeout: 3000#    writeTimeout: 3000#    wiretap: false#    pool:#      type: ELASTIC#      name: proxy#      maxConnections: 16#      acquireTimeout: 45000#    proxy:#      host:#      port:#      username:#      password:#      nonProxyHostsPattern:#    ssl:#      useInsecureTrustManager: false#      trustedX509Certificates:#      handshakeTimeout:#      closeNotifyFlushTimeout:#      closeNotifyReadTimeout:#      defaultConfigurationType:  sync:    websocket:      urls: ws://localhost:9095/websocket      allowOrigin: ws://localhost:9195#    zookeeper:#      url: localhost:2181#      sessionTimeout: 5000#      connectionTimeout: 2000#    http:#      url: http://localhost:9095#    nacos:#      url: localhost:8848#      namespace: 1c10d748-af86-43b9-8265-75f487d20c6c#      username:#      password:#      acm:#        enabled: false#        endpoint: acm.aliyun.com#        namespace:#        accessKey:#        secretKey:#    etcd:#      url: http://localhost:2379#    consul:#      url: http://localhost:8500#      waitTime: 1000#      watchDelay: 1000  cross:    enabled: true    allowedHeaders:    allowedMethods: "*"    allowedOrigin: "*"    allowedExpose: "*"    maxAge: "18000"    allowCredentials: true  switchConfig:    local: true  file:    enabled: true    maxSize : 10  exclude:    enabled: false    paths:      - /favicon.ico  extPlugin:    path:    enabled: true    threads: 1    scheduleTime: 300    scheduleDelay: 30  scheduler:    enabled: false    type: fixed    threads: 16  upstreamCheck:    enabled: false    timeout: 3000    healthyThreshold: 1    unhealthyThreshold: 1    interval: 5000    printEnabled: true    printInterval: 60000

Property Detail#

shenyu.NettyTcpConfig config#

ShenYu Netty config

NameTypeDefaultRequiredDescription
select.countint1NoNumber of netty selectors
worker.countint4NoNumber of netty workers
connect_timeout_millisint10000NoNetty config, the connect timeout of the channel in milliseconds
write_buffer_high_water_markint65536NoNetty config, the high water mark of the write buffer
write_buffer_low_water_markint32768NoNetty config, the low water mark of the write buffer
so_keepalivebooleanfalseNoSocket config, enable tcp keepalive
so_reuseaddrbooleanfalseNoSocket config, allow reuse of local addresses
so_lingerint-1NoSocket config, the delay time for closing the socket
so_backlogint128NoSocket config, maximum length of the accept queue
tcp_nodelaybooleantrueNoSocket config, enable Nagle algorithm
shenyu.httpclient config#

This is the HttpClient configuration used to send proxy requests after proxying the Http and SpringCloud protocols in the ShenYu gateway.

NameTypeDefaultRequiredDescription
strategyStringwebcwebClientNoThe strategy of httpClientPlugin
connectTimeoutint45000NoConnection timeout (millisecond), the default value is 45000.
readTimeoutint3000NoRead timeout (millisecond), the default value is 3000.
writeTimeoutint3000NoWrite timeout (millisecond), the default value is 3000.
wiretapBooleanfalseNoEnables wiretap debugging for Netty HttpClient, the default value is 'false'.
poolHttpClient connection pool config
proxyHttpClient proxy config
sslHttpClient ssl config
  • pool config

HttpClient connection pool configuration:

NameTypeDefaultRequiredDescription
typeStringELASTICNoType of pool for HttpClient to use, defaults to ELASTIC.
- ELASTIC: The connection pool can be cached and grown on demand
- FIXED: The connection pool cache and reuse a fixed maximum The number of connections.
- DISABLED: The connection pool will always create a new connection.
nameStringproxyNoThe channel pool map name, defaults to proxy.
maxConnectionsintthe maximum value of 2*CPU and 16NoOnly for type FIXED, the maximum number of connections before starting pending acquisition on existing ones.
the default value is available number of processors*2.
(but with a minimum value of 16)
acquireTimeoutint45000NoOnly for type FIXED, the maximum time in millis to wait for aquiring. the default value is 45000
  • proxy config

Netty HttpClient proxy configuration:

NameTypeDefaultRequiredDescription
hostStringnullNoHostname for proxy configuration of Netty HttpClient.
portStringnullNoPort for proxy configuration of Netty HttpClient.
usernameStringnullNoUsername for proxy configuration of Netty HttpClient.
passwordStringnullNoPassword for proxy configuration of Netty HttpClient.
nonProxyHostsPatternStringnullNoRegular expression (Java) for a configured list of hosts. that should be reached directly, bypassing the proxy
  • SSL config

Gateway routing can support routing to http and https back-end services at the same time. The following is the SSL-related configuration:

NameTypeDefaultRequiredDescription
useInsecureTrustManagerBooleanfalseNoInstalls the netty InsecureTrustManagerFactory. This is insecure and not suitable for production.
trustedX509CertificatesStringNullNoTrusted certificates for verifying the remote endpoint's certificate.(Use , to separate multiple values)
handshakeTimeoutint10000NoSSL handshake timeout. Default to 10000 ms
closeNotifyFlushTimeoutint3000NoSSL close_notify flush timeout. Default to 3000 ms.
closeNotifyReadTimeoutint0NoSSL close_notify read timeout. Default to 0 ms.
defaultConfigurationTypeStringTCPNoThe default ssl configuration type. Defaults to TCP.
- H2: SslProvider will be set depending on OpenSsl.isAlpnSupported(), SslProvider.HTTP2_CIPHERS, ALPN support, HTTP/1.1 and HTTP/2 support.
- TCP: SslProvider will be set depending on OpenSsl.isAvailable()
- NONE: There will be no default configuration
Filter Configuration#
  • shenyu.file config

File filter properties:

NameTypeDefaultRequiredDescription
enabledBooleanfalseNoenable file size filtering
maxSizeInteger10Noupload file maxSize (MB)
  • shenyu.cross config

Cross filter properties:

NameTypeDefaultRequiredDescription
enabledBooleanfalseNoallow cross-domain requests
allowedHeadersStringx-requested-with, authorization, Content-Type, Authorization, credential, X-XSRF-TOKEN, token, username, clientNoallowedHeaders, Use "," split in multiple cases. the new "allowedHeaders" will append to "Access-Control-Allow-Headers" based on the default value and remove the reduplicative header.
allowedMethodsString"*"NoallowedMethods
allowedOriginString"*"NoallowedOrigin
allowedExposeString"*"NoallowedExpose
maxAgeString"18000"NomaxAge (ms)
allowCredentialsBooleantrueNoallowCredentials
  • shenyu.exclude config

Exculde filter properties:

NameTypeDefaultRequiredDescription
enabledBooleanfalseNowhether to enable exclude filter and reject the specified request to pass through the gateway
pathsArraynullYesRequests matching this list can not pass through the gateway (support Path-Matching)
shenyu.sync config#

The Apache ShenYu gateway and the Admin System use data synchronization configurations.

The following properties are configured for data synchronization using websocket :

NameTypeDefaultRequiredDescription
urlsStringnullYesThe websocket server address of Admin, separate multiple addresses with ,

The following properties are configured for data synchronization using zookeeper :

NameTypeDefaultRequiredDescription
urlStringnullYeszookeeper server url
sessionTimeoutintnullYessession timeout (millisecond)
connectionTimeoutintnullYesconnection timeout (millisecond)

The following properties are configured for data synchronization using http long polling :

NameTypeDefaultRequiredDescription
urlStringnullYesAdmin server address

The following properties are configured for data synchronization using nacos :

NameTypeDefaultRequiredDescription
urlStringnullnacos url
namespaceStringnullYesnamespace
usernameStringnullNousername
passwordStringnullNopassword
acmNoaliyun ACM service configuration
  • acm config
NameTypeDefaultRequiredDescription
enabledbooleanfalseNowhether to enable
endpointStringnullNoACM service address
namespaceStringnullNonamespace
accessKeyStringnullNoaccessKey
secretKeyStringnullNosecretKey

The following properties are configured for data synchronization using etcd :

NameTypeDefaultRequiredDescription
urlStringnullYesetcd server url

The following properties are configured for data synchronization using consul :

NameTypeDefaultRequiredDescription
urlStringnullYesconsul server url
waitTimeintnullYesthe timeout period for requesting consul service to pull configuration information (milliseconds)
watchDelayintnullYesSynchronization interval (milliseconds)
shenyu.extPlugin config#

The Apache ShenYu Supports dynamic loading of custom plug-ins with the following configuration

NameTypeDefaultRequiredDescription
enabledBooleantrueNoopen dynamic loading of custom plug-ins
pathStringFalsecustom plugins path, if not config, the path is /ext/lib
threadsInteger1Falsethreads for dynamic loading custom plug-ins
scheduleTimeInteger300Falseschedule time (s) for dynamic loading custom plug-ins
scheduleDelayInteger30Falseschedule delay when app startup
shenyu.scheduler config#

scheduler config for Apache ShenYu Scheduler Thread Model

NameTypeDefaultRequiredDescription
enabledBooleanfalseNoWhether to turn on Scheduler Thread Model
typeStringfixedFalsefixed Thread Pool or elastic Scheduler Thread Model
threadsIntegerMath.max((Runtime.getRuntime().availableProcessors() << 1) + 1, 16)Falsethreads for fixed Thread Pool
shenyu.upstreamCheck config#

upstreamCheck config is the configuration used by Apache ShenYu to detect upstream

NameTypeDefaultRequiredDescription
enabledBooleanfalseNoWhether to turn on upstreamCheck
timeoutInteger3000Falsetimeout (ms)
healthyThresholdInteger1FalsehealthyThreshold
unhealthyThresholdInteger1FalseunhealthyThreshold
intervalInteger5000Falseschedule time (ms) for checked
printEnabledBooleantrueNoWhether to turn on print logs
printIntervalInteger60000Falseschedule time (ms) for print logs
shenyu.switchConfig config#

Apache ShenYu Switch Config

NameTypeDefaultRequiredDescription
localBooleantrueNoWhether to open local mode, if so, local operation data, default open