Skip to main content

RelyREST Server Reference

RelyServerConfig

RelyServerConfig holds information of required configurations to run the Rely API server.

KeyValueRequiredDescription
serverServerConfigfalseConfigurations for the HTTP server.
telemetryOTLPConfigfalseConfigurations for OpenTelemetry exporters.
definitionRelyDefinitionFileConfigtrueConfigurations for resource definition files.

RelyDefinitionFileConfig

RelyDefinitionFileConfig represents the configurations for definition files.

KeyValueRequiredDescription
include[string]trueList of paths to be included for metadata introspection.
exclude[string]falseList of paths to be excluded for metadata introspection.

OTLPConfig

OTLPConfig contains configuration for OpenTelemetry exporter.

KeyValueRequiredDescription
serviceNamestringfalseOpenTelemetry service name.
otlpEndpointstringfalseOTLP receiver endpoint that is set as default for all types.
otlpTracesEndpointstringfalseOTLP receiver endpoint for traces exporter.
otlpMetricsEndpointstringfalseOTLP receiver endpoint for metrics exporter.
otlpLogsEndpointstringfalseOTLP receiver endpoint for logs exporter.
otlpInsecurebooleanfalseDisable TLS for OpenTelemetry exporters.
otlpTracesInsecurebooleanfalseDisable TLS for OpenTelemetry traces exporter.
otlpMetricsInsecurebooleanfalseDisable TLS for OpenTelemetry metrics exporter.
otlpLogsInsecurebooleanfalseDisable TLS for OpenTelemetry logs exporter.
otlpProtocolgrpc / http/protobuffalseOTLP receiver protocol for all exporters. Default is grpc.
otlpTracesProtocolgrpc / http/protobuffalseOTLP receiver protocol for traces.
otlpMetricsProtocolgrpc / http/protobuffalseOTLP receiver protocol for metrics.
otlpLogsProtocolgrpc / http/protobuffalseOTLP receiver protocol for logs.
otlpCompressionnone / gzipfalseEnable compression for OTLP exporters. Accept: none, gzip
otlpTracesCompressionnone / gzipfalseEnable compression for OTLP traces exporter. Accept: none, gzip
otlpMetricsCompressionnone / gzipfalseEnable compression for OTLP metrics exporter. Accept: none, gzip
otlpLogsCompressionnone / gzipfalseEnable compression for OTLP logs exporter. Accept: none, gzip
metricsExporternone / otlp / prometheusfalseMetrics export type. Accept: none, otlp, prometheus
logsExporternone / otlpfalseLogs export type. Accept: none, otlp
prometheusPortintegerfalsePrometheus port for the Prometheus HTTP server. Use /metrics endpoint of the connector server if empty.
disableGoMetricsbooleanfalseDisable internal Go and process metrics (prometheus exporter only).

ServerConfig

ServerConfig holds information of required environment variables.

KeyValueRequiredDescription
portintegerfalseThe port where the server is listening to.
logLevelINFO / DEBUG / WARN / ERRORfalseLevel of the logger.
compressionLevelintegerfalseDefault level which the server uses to compress response bodies.
requestTimeoutstringfalseThe default timeout of every request. Return a 504 Gateway Timeout error to the client.
readTimeoutstringfalseThe maximum duration for reading the entire request, including the body. A zero or negative value means there will be no timeout.
readHeaderTimeoutstringfalseThe amount of time allowed to read request headers. The connection's read deadline is reset after reading the headers and the Handler can decide what is considered too slow for the body. If zero, the value of ReadTimeout is used. If negative, or if zero and ReadTimeout is zero or negative, there is no timeout.
writeTimeoutstringfalseThe maximum duration before timing out writes of the response. It is reset whenever a new request's header is read. Like ReadTimeout, it does not let Handlers make decisions on a per-request basis. A zero or negative value means there will be no timeout.
idleTimeoutstringfalseThe maximum amount of time to wait for the next request when keep-alives are enabled. If zero, the value of ReadTimeout is used. If negative, or if zero and ReadTimeout is zero or negative, there is no timeout.
maxHeaderKilobytesintegerfalseThe maximum number of bytes the server will read parsing the request header's keys and values, including the request line. It does not limit the size of the request body. If zero, DefaultMaxHeaderBytes is used.
maxBodyKilobytesintegerfalseThe maximum number of bytes the server will read parsing the request body. A zero or negative value means there will be no limit.
tlsCertFilestringfalseThe TLS certificate file to enable TLS connections.
tlsKeyFilestringfalseThe TLS key file to enable TLS connections.
corsCORSConfigfalseThe configuration container to setup the CORS middleware.
clientIpClientIPConfigfalseThe configuration container to setup the client IP middleware.

ClientIPConfig

The configuration container to setup the client IP middleware.

One of the following values:

ValueDescription
ServerClientIPFromHeaderConfigConfiguration for client IP resolution from headers. Only safe with headers your proxy unconditionally OVERWRITES on every request.
ServerClientIPFromRemoteAddressConfigConfiguration for client IP resolution from the remote address of the incoming request — the IP address of whoever opened the connection to this server. Use this strategy when this server is directly connected to the public internet with NO reverse proxy in front of it. Behind a reverse proxy, RemoteAddr is the proxy's IP, not the client's — use ClientIPFromHeader or ClientIPFromXFF instead
ServerClientIPFromXForwardForConfigConfiguration for client IP resolution from X-Forwarded-For header with trusted IP prefixes, walking the chain right-to-left and skipping any IP that falls within one of the given trusted CIDR prefixes.
ServerClientIPFromXForwardForTrustedProxiesConfigConfiguration for client IP resolution from X-Forwarded-For header given the exact number of trusted reverse proxies between this server and the public internet. It returns the IP at position len(xff) - numTrustedProxies in the merged X-Forwarded-For list — the IP added by the outermost of your trusted proxies, the only IP in the chain that none of your proxies have allowed an attacker to forge.

ServerClientIPFromXForwardForTrustedProxiesConfig

Configuration for client IP resolution from X-Forwarded-For header given the exact number of trusted reverse proxies between this server and the public internet. It returns the IP at position len(xff) - numTrustedProxies in the merged X-Forwarded-For list — the IP added by the outermost of your trusted proxies, the only IP in the chain that none of your proxies have allowed an attacker to forge.

KeyValueRequiredDescription
typex_forwarded_for_trusted_proxiestrueType of the strategy that the client IP should be parsed from.
numTrustedProxiesintegertrueThe exact number of trusted reverse proxies between this server and the public internet.

ServerClientIPFromXForwardForConfig

Configuration for client IP resolution from X-Forwarded-For header with trusted IP prefixes, walking the chain right-to-left and skipping any IP that falls within one of the given trusted CIDR prefixes.

KeyValueRequiredDescription
typex_forwarded_fortrueType of the strategy that the client IP should be parsed from.
trustedIpPrefixes[string]trueList of CIDR prefixes to be trusted when parsing the client IP from the X-Forwarded-For header.

ServerClientIPFromRemoteAddressConfig

Configuration for client IP resolution from the remote address of the incoming request — the IP address of whoever opened the connection to this server. Use this strategy when this server is directly connected to the public internet with NO reverse proxy in front of it. Behind a reverse proxy, RemoteAddr is the proxy's IP, not the client's — use ClientIPFromHeader or ClientIPFromXFF instead

KeyValueRequiredDescription
typeremote_addrtrueType of the strategy that the client IP should be parsed from.

ServerClientIPFromHeaderConfig

Configuration for client IP resolution from headers. Only safe with headers your proxy unconditionally OVERWRITES on every request.

KeyValueRequiredDescription
typeheadertrueType of the strategy that the client IP should be parsed from.
headers[string]trueList of headers to be looked up

CORSConfig

CORSConfig represents configurations of CORS.

KeyValueRequiredDescription
allowedOrigins[string]falseAllowedOrigins is a list of origins a cross-domain request can be executed from. If the special "" value is present in the list, all origins will be allowed. An origin may contain a wildcard () to replace 0 or more characters (i.e.: http://*.domain.com). Usage of wildcards implies a small performance penalty. Only one wildcard can be used per origin. CORS is disabled if empty.
allowedMethods[string]falseAllowedMethods is a list of methods the client is allowed to use with cross-domain requests. Default value is simple methods (HEAD, GET and POST).
allowedHeaders[string]falseAllowedHeaders is list of non simple headers the client is allowed to use with cross-domain requests. If the special "*" value is present in the list, all headers will be allowed. Default value is [] but "Origin" is always appended to the list.
exposedHeaders[string]falseExposedHeaders indicates which headers are safe to expose to the API of a CORS API specification
maxAgeintegerfalseMaxAge indicates how long (in seconds) the results of a preflight request can be cached
allowCredentialsbooleanfalseAllowCredentials indicates whether the request can include user credentials like cookies, HTTP authentication or client side SSL certificates.
optionsPassthroughbooleanfalseOptionsPassthrough instructs preflight to let other potential next handlers to process the OPTIONS method. Turn this on if your application handles OPTIONS.