FastProxy Configuration Options: A Complete Guide to Client and Server Settings
FastProxy supports two operational modes—in-proxy (client) and out-proxy (server)—with configuration options defined in YAML files that map to Go interfaces in common/config, inproxy/inconfig, and outproxy/outconfig packages.
FastProxy is a high-performance proxy solution developed in the kingson4wu/fast_proxy repository that enables secure, encrypted communication between distributed services. Understanding the available FastProxy configuration options is essential for deploying the in-proxy client mode and out-proxy server mode effectively. This guide details every configurable field, its purpose, and the specific source files where these settings are defined.
Common Core Configuration Options
These options are defined in common/config/config.go and are available to both in-proxy and out-proxy modes.
| Option | Type | Description |
|---|---|---|
EncryptKeyName |
string |
Name of the encryption key to use (encrypt.key.name). |
SignKeyName |
string |
Name of the signing key (sign.key.name). |
EncryptEnable |
bool |
Toggle request/response encryption. |
SignEnable |
bool |
Toggle request/response signing. |
CompressEnable |
bool |
Enable payload compression. |
CompressAlgorithm |
int32 |
Compression algorithm identifier (compress.algorithm). |
ServerName |
string |
Logical name of the service host. |
ServerPort |
int |
Port on which the service listens. |
ServiceRpcHeaderName |
string |
Header name that carries the target service name (rpc.serviceHeaderName). |
HttpClientMaxIdleConns |
int |
Maximum idle HTTP client connections. |
HttpClientMaxIdleConnsPerHost |
int |
Maximum idle connections per host. |
FastHttpEnable |
bool |
Enable the fasthttp server implementation. |
Security and Encryption Settings
The EncryptKeyName, SignKeyName, EncryptEnable, and SignEnable fields control the cryptographic layer. When enabled, FastProxy uses the specified key names to look up actual secret values in encryptKeyConfig and signKeyConfig maps defined in your YAML file.
Network and HTTP Client Settings
HttpClientMaxIdleConns and HttpClientMaxIdleConnsPerHost tune the connection pool for outbound requests. Setting FastHttpEnable to true switches the underlying server implementation from standard net/http to valyala/fasthttp for better performance under high concurrency.
Service-Level Configuration
The ServiceConfig struct groups per-service toggles including EncryptEnable, SignEnable, CompressEnable, and CompressAlgorithm. ServiceTimeoutConfig allows setting timeout values in milliseconds for specific service calls, ensuring granular control over service-level behavior.
In-Proxy (Client) Configuration Options
Implemented in inproxy/inconfig, with the interface declared in config.go and YAML loading logic in yaml_config.go. The in-proxy mode acts as the client-side component that forwards requests to the out-proxy server.
| Setting (YAML key) | Type | Meaning |
|---|---|---|
application.name |
string |
Logical name of the in-proxy instance. |
application.port |
int |
Port on which the in-proxy HTTP server runs. |
application.contextPath |
string |
Base path for the in-proxy API (e.g. /inProxy). |
rpc.serviceHeaderName |
string |
Header that carries the downstream service name. |
proxy.forwardAddress |
string |
(Out-proxy) URL to which the in-proxy forwards traffic. |
serviceConfig.<service> |
object | Per-service toggles (encryptEnable, signEnable, compressEnable) and key names. |
signKeyConfig.<keyName> |
string |
Mapping of signing key names to secret values. |
encryptKeyConfig.<keyName> |
string |
Mapping of encryption key names to secret strings. |
serviceCallTypeConfig.<service>.<uri>.callType |
int |
Call-type flag (e.g., 1 for async). |
serviceCallTypeConfig.<service>.<uri>.qps |
int |
QPS limit for the specific endpoint. |
httpClient.MaxIdleConns |
int |
Overrides the common HTTP client idle-conn limit. |
httpClient.MaxIdleConnsPerHost |
int |
Overrides per-host idle-conn limit. |
fastHttp.enable |
bool |
Use the fasthttp implementation for the in-proxy server. |
Application Settings
The application block defines the runtime identity of the in-proxy instance, including its name, port, and contextPath. These values determine how the client-side proxy exposes its HTTP interface and handles incoming requests before forwarding them to the out-proxy.
Service Routing and Call Types
The serviceCallTypeConfig section enables granular control over individual endpoints. You can specify callType flags (such as 1 for asynchronous processing) and apply qps rate limits to specific service URIs, preventing downstream overload.
Accessing In-Proxy Configuration in Code
To load and access configuration values programmatically in the in-proxy mode:
import "github.com/Kingson4wu/fast_proxy/inproxy/inconfig"
// Load a YAML file (bytes) into the config implementation
cfg := inconfig.LoadYamlConfig(yamlBytes)
// Register the config globally
inconfig.Read(cfg)
// Retrieve configuration values
ctxPath := inconfig.Get().ServerContextPath()
callType := inconfig.Get().GetCallTypeConfigByName("song_service", "/token_service/api/service")
qps := inconfig.Get().ServiceQps("song_service", "/token_service/api/service")
hasPrivilege := inconfig.Get().ContainsCallPrivilege("song_service", "/token_service/api/service")
Out-Proxy (Server) Configuration Options
Implemented in outproxy/outconfig, with the interface declared in config.go and YAML loading logic in yaml_config.go. The out-proxy acts as the server-side component that receives forwarded requests and routes them to upstream services.
| Setting (YAML key) | Type | Meaning |
|---|---|---|
proxy.forwardAddress |
string |
Destination address for reverse-proxy forwarding (used by out-proxy to send traffic to the real upstream). |
application.name |
string |
Logical name of the out-proxy instance. |
application.port |
int |
Port on which the out-proxy server listens. |
application.contextPath |
string |
Base context path for the out-proxy API (e.g., /outProxy). |
rpc.serviceHeaderName |
string |
Header name that carries the downstream service identifier. |
serviceConfig.<service> |
object | Same per-service toggles & key names as in in-proxy. |
signKeyConfig / encryptKeyConfig |
map | Same key-name → secret mappings as in in-proxy. |
httpClient.MaxIdleConns / MaxIdleConnsPerHost |
int |
HTTP client connection pool settings for outbound calls. |
fastHttp.enable |
bool |
Switch to the fasthttp server for the out-proxy. |
Reverse Proxy Settings
The proxy.forwardAddress field is specific to the out-proxy mode. It defines the upstream URL where the server-side proxy forwards incoming requests after processing security headers, decryption, and decompression.
Accessing Out-Proxy Configuration in Code
To load and access configuration values programmatically in the out-proxy mode:
import "github.com/Kingson4wu/fast_proxy/outproxy/outconfig"
cfg := outconfig.LoadYamlConfig(yamlBytes)
outconfig.Read(cfg)
forward := outconfig.Get().ForwardAddress()
Complete Configuration Example
Below is a minimal but complete YAML configuration that works for both modes, combining common core settings with mode-specific fields:
# Shared application info
application:
name: my_proxy
port: 8080
contextPath: /proxy
# RPC header used to convey service name
rpc:
serviceHeaderName: C_ServiceName
# Out-proxy forwarding target
proxy:
forwardAddress: http://127.0.0.1:9833/inProxy
# Service-level encryption / signing options
serviceConfig:
song_service:
encryptKeyName: encrypt.key.room.v2
signKeyName: sign.key.room.v1
encryptEnable: true
signEnable: true
compressEnable: true
# Key/value mappings
signKeyConfig:
sign.key.room.v1: abcd
sign.key.room.v2: efgh
encryptKeyConfig:
encrypt.key.room.v1: ABCDABCDABCDABCDW
encrypt.key.room.v2: WXYZWXYZWXYZWXYZ
# Call-type & QPS limits per endpoint
serviceCallTypeConfig:
song_service:
/token_service/api/service:
callType: 1
qps: 10
# HTTP client pool tuning
httpClient:
MaxIdleConns: 5000
MaxIdleConnsPerHost: 3000
# Fast-HTTP toggle
fastHttp:
enable: true
All keys correspond directly to the structs and interfaces described in the source files.
Summary
- FastProxy configuration options are centralized in
common/config/config.gofor shared settings, while mode-specific logic resides ininproxy/inconfigandoutproxy/outconfig. - Both in-proxy and out-proxy support encryption, signing, and compression through YAML keys like
encryptEnable,signKeyConfig, andcompressAlgorithm. - In-proxy adds client-specific routing controls including
serviceCallTypeConfigfor QPS limits and asynchronous call types. - Out-proxy adds
proxy.forwardAddressto define upstream routing targets for reverse proxy operations. - Configuration is loaded via
LoadYamlConfig()and registered globally usingRead(), enabling runtime access throughGet()methods in both modes.
Frequently Asked Questions
How do I configure encryption keys in FastProxy?
Define the key names in the serviceConfig.<service>.encryptKeyName field, then map those names to actual secret values in the top-level encryptKeyConfig section of your YAML file. The in-proxy and out-proxy both use these mappings to perform encryption and decryption operations.
What is the difference between in-proxy and out-proxy configuration?
In-proxy configuration focuses on client-side concerns such as application.port, application.contextPath, and serviceCallTypeConfig for routing outbound requests. Out-proxy configuration centers on server-side reverse proxy behavior, primarily using proxy.forwardAddress to determine where to send traffic after processing security headers.
How do I enable fasthttp instead of standard net/http?
Set fastHttp.enable: true in your YAML configuration file. This toggle, defined in the common core options, switches both in-proxy and out-proxy servers from the standard library's net/http to the high-performance valyala/fasthttp implementation.
Where are configuration files loaded in the FastProxy codebase?
YAML configuration is loaded through LoadYamlConfig() functions found in inproxy/inconfig/yaml_config.go for client mode and outproxy/outconfig/yaml_config.go for server mode. These functions parse the YAML into Go structs defined in the respective config.go interface files.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →