### GET / Source: https://github.com/yyyar/gobetween/wiki/REST-API Returns system information about the gobetween process, including configuration, PID, start time, current time, uptime, and version. ```APIDOC ## GET / ### Description Returns system information about the gobetween process. ### Method GET ### Endpoint / ### Response #### Success Response (200) - **configuration** (object) - The current configuration, kind-specific data. - **pid** (integer) - Process ID. - **startTime** (string) - Start time of the process. - **time** (string) - Current time. - **uptime** (duration) - Uptime of the process. - **version** (string) - Version of gobetween. #### Response Example ```json { "configuration": { "kind" : "string" // ... // kind-specific data }, "pid": 1234, "startTime": "2023-01-01T00:00:00Z", "time": "2023-01-01T00:00:01Z", "uptime": "1m", "version": "0.7.0" } ``` ``` -------------------------------- ### Install gobetween via Snap (edge) Source: https://github.com/yyyar/gobetween/wiki/Installation Installs the latest development version of gobetween from the Snap Store. Requires Ubuntu or a system with snap installed. ```bash sudo snap install gobetween --edge ``` -------------------------------- ### Install gobetween from sources Source: https://github.com/yyyar/gobetween/wiki/Installation Clones the repository, builds, installs, and runs gobetween from source. Includes editing the configuration file. ```bash git clone git@github.com:yyyar/gobetween.git make sudo -E make install vim /etc/gobetween.toml gobetween -c /etc/gobetween.toml ``` -------------------------------- ### Start gobetween Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Command to start gobetween. The actual command is not provided; only a comment placeholder is shown. ```bash #start gobetween ``` -------------------------------- ### Exec discovery example script Source: https://github.com/yyyar/gobetween/wiki/Discovery Example script for exec discovery. It outputs backends in the expected format. The gobetween process must have execute permission to the script. ```bash #!/usr/bin/env bash echo localhost:8000 weight=1 echo localhost:8001 weight=2 ``` -------------------------------- ### Install Consul binary Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Commands to download, unzip, and install Consul 0.6.4 on each Consul server. ```bash #wget https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_amd64.zip #unzip *.zip #mv consul /usr/sbin/consul ``` -------------------------------- ### Run gobetween Source: https://github.com/yyyar/gobetween/wiki/Installation Starts gobetween with the specified configuration file using sudo. ```bash sudo gobetween -c config/gobetween.toml ``` -------------------------------- ### Install Docker Engine on Ubuntu Trusty Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Commands to install Docker Engine on Ubuntu Trusty, including adding the Docker repository and installing required packages. Run as root (sudo). ```bash # sudo apt-get update # sudo apt-get install apt-transport-https ca-certificates #sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D #echo “deb https://apt.dockerproject.org/repo ubuntu-trusty main” > /etc/apt/sources.list.d/docker.list #sudo apt-get update #sudo apt-get purge lxc-docker #apt-cache policy docker-engine #sudo apt-get update #sudo apt-get install linux-image-extra-$(uname -r) #apt-get install apparmor #sudo apt-get install docker-engine #sudo docker run hello-world ``` -------------------------------- ### Start gobetween from file, URL, or Consul KV Source: https://github.com/yyyar/gobetween/wiki/Configuration Commands to start gobetween with configuration from a local file, a URL, or a Consul KV store. The from-consul command uses the --key, --scheme, and -f flags to specify the key, scheme, and format. ```bash $ gobetween from-file /path/to/gobetween.toml ``` ```bash $ gobetween from-url http://some.url/gobetween.toml ``` ```bash $ gobetween from-consul localhost:8500 --key=gobetween --scheme=http -f json ``` -------------------------------- ### GET /servers Source: https://github.com/yyyar/gobetween/wiki/REST-API Lists all servers configured in gobetween. ```APIDOC ## GET /servers ### Description Lists all servers configured in gobetween. ### Method GET ### Endpoint /servers ### Response #### Success Response (200) - **** (object) - A map of server names to their definitions, same structure as `[servers]` entries in the config TOML file. #### Response Example ```json { "": { // server definition of the same structure and format as `[servers.]` // entry in config TOML file but JSON encoded. }, // other servers } ``` ``` -------------------------------- ### SRV DNS query example Source: https://github.com/yyyar/gobetween/wiki/Discovery Example of a dig command for SRV records, showing how gobetween uses SRV targets as SNI hostnames. ```text dig @192.168.0.5 foo.service.consul SRV ;; ANSWER SECTION: foo.service.consul. 0 IN SRV 1 1 8443 foo.com. foo.service.consul. 0 IN SRV 1 1 8443 bar.com. foo.service.consul. 0 IN SRV 1 1 8443 baz.com. ``` -------------------------------- ### Run gobetween and test with curl Source: https://github.com/yyyar/gobetween/blob/master/README.md Start gobetween with a config file and test it with curl. Requires localhost:8000 and localhost:8001 in the static_list of the config. ```bash $ gobetween -c gobetween.toml ``` ```bash $ curl http://localhost:3000 ``` -------------------------------- ### GET / - System Information response Source: https://github.com/yyyar/gobetween/wiki/REST-API JSON response structure for the system information endpoint. Contains configuration, process ID, start time, current time, uptime, and version. ```js { "configuration": { "kind" : String // ... // kind-specific data }, "pid": Integer, "startTime": String, "time": String, "uptime": Duration, "version": String } ``` -------------------------------- ### Full Access Control TOML Example Source: https://github.com/yyyar/gobetween/wiki/Access-Control Complete TOML configuration for access control with a default policy of "deny" and a rules list. This example can be added to the config file under [servers.servername.access]. ```toml [servers.servername.access] default = "deny" rules = [ "allow 127.0.0.1", "deny 192.168.1.0/24", "allow 192.168.0.0/16", "allow 10.0.0.0/16", ] ``` -------------------------------- ### Start test web servers Source: https://github.com/yyyar/gobetween/blob/master/README.md Run two simple HTTP servers on ports 8000 and 8001 for testing. Use Python's built-in HTTP module. ```bash $ python -m SimpleHTTPServer 8000 ``` ```bash $ python -m SimpleHTTPServer 8001 ``` -------------------------------- ### Weighted backend pool example Source: https://github.com/yyyar/gobetween/wiki/Balancing Example of a backend pool with weight and priority properties. Used to illustrate the weight balancing strategy where selection probability is proportional to weight, and priority determines order. ```json [ "host1 weight=1 priority=1" "host2 weight=2 priority=1" ] ``` -------------------------------- ### Config file with environment variable placeholders Source: https://github.com/yyyar/gobetween/wiki/env-vars-substitution Placeholders use the ${VAR} syntax. In this example, ${HOST} and ${PORT} will be replaced by environment variables. ```toml [servers.sample] protocol = "tcp" bind = "${HOST}:${PORT}" ``` -------------------------------- ### Linux exec_command configuration Source: https://github.com/yyyar/gobetween/wiki/Windows-specific-notes Example of exec_command configuration for Linux, using double quotes for paths. ```toml exec_command = "/etc/gobetween/healthchecks/exec_healthcheck.sh" exec_command = ["/etc/gobetween/scripts/discovery/exec_discovery.sh", "arg1", "arg2"] ``` -------------------------------- ### GET /servers - List All Servers response Source: https://github.com/yyyar/gobetween/wiki/REST-API JSON response structure for listing all servers, with each server keyed by name and containing its definition in the same format as the [servers] section of the config. ```js { // Represents the same structure and format as `[servers]` entries in config TOML file. "": { // server definition of the same structure and format as `[servers.]` // entry in config TOML file but JSON encoded. }, // other servers } ``` -------------------------------- ### GET /dump Source: https://github.com/yyyar/gobetween/wiki/REST-API Dumps the current configuration in TOML or JSON format as specified by the query parameter. ```APIDOC ## GET /dump ### Description Dumps the current configuration in TOML or JSON format as specified by the query parameter. ### Method GET ### Endpoint /dump ### Parameters #### Query Parameters - **format** (string) - Optional - Format of the dump: "toml" (default) or "json". ### Response #### Success Response (200) - **body** (string) - The current configuration in the requested format. #### Response Example ``` # TOML or JSON formatted current config ``` ``` -------------------------------- ### Run nginx containers for service1 and service2 on server2 Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Two docker run commands to start nginx containers with labels and environment variables for service discovery. SERVICE_80_NAME sets the service name, and the /tmp/test directory is mounted read-only. ```bash docker run -l proxied=true -d -p 22002:80 -e "SERVICE_80_NAME=service1" -v /tmp/test:/usr/share/nginx/html:ro nginx docker run -l proxied=true -d -p 23002:80 -e "SERVICE_80_NAME=service2" -v /tmp/test2:/usr/share/nginx/html:ro nginx ``` -------------------------------- ### Run nginx containers for service1 and service2 on server1 Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Two docker run commands to start nginx containers with labels and environment variables for service discovery. SERVICE_80_NAME sets the service name, and the /tmp/test directory is mounted read-only. ```bash docker run -l proxied=true -d -p 22001:80 -e "SERVICE_80_NAME=service1" -v /tmp/test:/usr/share/nginx/html:ro nginx docker run -l proxied=true -d -p 23001:80 -e "SERVICE_80_NAME=service2" -v /tmp/test2:/usr/share/nginx/html:ro nginx ``` -------------------------------- ### Run nginx containers for service1 and service2 on server3 Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Two docker run commands to start nginx containers with labels and environment variables for service discovery. SERVICE_80_NAME sets the service name, and the /tmp/test directory is mounted read-only. ```bash docker run -l proxied=true -d -p 22003:80 -e "SERVICE_80_NAME=service1" -v /tmp/test:/usr/share/nginx/html:ro nginx docker run -l proxied=true -d -p 23003:80 -e "SERVICE_80_NAME=service2" -v /tmp/test2:/usr/share/nginx/html:ro nginx ``` -------------------------------- ### Basic gobetween server configuration with static discovery and weight balancing Source: https://github.com/yyyar/gobetween/wiki/Static-balancing Defines a gobetween server named 'sample' that listens on 100.100.1.5:3000, uses TCP protocol with weight-based balancing, and discovers three static backends with specified weights. Includes connection limits and timeouts. ```toml [servers.sample] bind = "100.100.1.5:3000" protocol = "tcp" balance = "weight" max_connections = 10000 client_idle_timeout = "10m" backend_idle_timeout = "10m" backend_connection_timeout = "2s" [servers.sample.discovery] kind = "static" static_list = [ "10.0.0.2:22399 weight=5", "10.0.0.3:22499 weight=3", "10.0.0.5:32399 weight=1" ] ``` -------------------------------- ### Download gobetween init script Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Downloads the gobetween init script from the repository to be placed in /etc/init/. ```bash #wget https://github.com/yyyar/gobetween/blob/master/config/init/gobetween.conf ``` -------------------------------- ### Clone and build gobetween Source: https://github.com/yyyar/gobetween/blob/master/README.md Commands to clone the repository and build/run the project. Requires Go 1.24+. ```bash $ git clone git@github.com:yyyar/gobetween.git ``` ```bash $ make ``` ```bash $ make run ``` -------------------------------- ### Plaintext discovery example response Source: https://github.com/yyyar/gobetween/wiki/Discovery Example plaintext responses that the default regex can parse. Each line represents one backend. ```text 0.0.0.0:1234 weight=0 priority=1 0.0.0.0:4321 weight=1 priority=0 sni=host.com ``` -------------------------------- ### Access Control Rules List Example Source: https://github.com/yyyar/gobetween/wiki/Access-Control Example of a rules list for access control. Rules are checked from top to bottom, and the first match stops the check. In this example, packets from 192.168.1.0/24 are rejected even though they are included in the broader 192.168.0.0/16 subnet listed later. ```plaintext rules = [ "allow 127.0.0.1", "deny 192.168.1.0/24", "allow 192.168.0.0/16", "allow 10.0.0.0/16", ] ``` -------------------------------- ### Create gobetween directory Source: https://github.com/yyyar/gobetween/wiki/Installation Creates a directory named 'gobetween' and changes into it, preparing for downloading the binary. ```bash mkdir gobetween cd gobetween ``` -------------------------------- ### Start Consul cluster on other servers Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Starts the Consul cluster on the other two servers (sever2 and sever3). They connect to the bootstrapped server to form the cluster. ```bash #start consul ``` -------------------------------- ### Configure gobetween Source: https://github.com/yyyar/gobetween/wiki/Installation Opens the default configuration file in vim for editing. ```bash vim config/gobetween.toml ``` -------------------------------- ### Start Consul bootstrap agent Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Starts the Consul agent in bootstrap mode on sever1.consul.example.com. The server self-elects as leader and occupies the terminal window. ```bash #consul agent -config-dir /etc/consul.d/bootstrap ``` -------------------------------- ### Run gobetween with environment variables set Source: https://github.com/yyyar/gobetween/wiki/env-vars-substitution Sets HOST and PORT environment variables and runs gobetween with the -e flag and a config file. ```bash HOST=localhost PORT=3000 gobetween -e -c example-config.toml ``` -------------------------------- ### GET /servers/ - Get Server By Name response Source: https://github.com/yyyar/gobetween/wiki/REST-API JSON response structure for retrieving a single server definition, matching the format of the [servers.] entry in the config TOML file. ```js { // server definition of the same structure and format as `[servers.]` // entry in config TOML file but JSON encoded. } ``` -------------------------------- ### Local LXD Server Configuration (unix sockets) Source: https://github.com/yyyar/gobetween/wiki/Discovery Configuration for gobetween to query a local LXD server via unix socket. Includes optional filtering by container label and port key, or hardcoded port. Must be able to access containers remotely. ```toml [servers.example] # ... [servers.example.discovery] kind = "lxd" lxd_server_address = "unix:///var/lib/lxd/unix.socket" # (optional) Filter containers with specified setting key and value lxd_container_label_key = "user.gobetween.label" lxd_container_label_value = "web" # Take server port from specified setting key lxd_container_port_key = "user.gobetween.port" # OR use specified port lxd_container_port = 12345 ``` -------------------------------- ### Create test HTML files for service1 and service2 on server1 Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Content for /tmp/test/test_service.html and /tmp/test2/test_service.html on server1.application1.example.com to identify service1 and service2 during proxy testing. ```text Server1.application1.example.com service1 ``` ```text Server1.application1.example.com service2 ``` -------------------------------- ### GET /servers//stats - Get Server Statistics response Source: https://github.com/yyyar/gobetween/wiki/REST-API JSON response structure for server statistics, including active connections, total and per-second byte counts, and per-backend stats with live/discovered status and connection counters. ```js { "active_connections": Integer, "rx_total": Integer, // bytes "tx_total": Integer, // bytes "rx_second": Integer, // bytes/second "tx_second": Integer, // bytes/second "backends": [ { "host": String, "port": String, "priority": Integer, "weight": Integer, "stats": { "live": Boolean, "discovered": Boolean, "total_connections": Integer, "active_connections": Integer, "refused_connections": Integer, "rx": Integer, // bytes "tx": Integer // bytes "rx_second": Integer, // bytes/second "tx_second": Integer, // bytes/second } }, // ... other backends ... ] } ``` -------------------------------- ### Create test HTML files for service1 and service2 on server2 Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Content for /tmp/test/test_service.html and /tmp/test2/test_service.html on server2.application1.example.com to identify service1 and service2 during proxy testing. ```text Server2.application1.example.com service1 ``` ```text Server2.application1.example.com service2 ``` -------------------------------- ### Create test HTML files for service1 and service2 on server3 Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Content for /tmp/test/test_service.html and /tmp/test2/test_service.html on server3.application1.example.com to identify service1 and service2 during proxy testing. ```text Server3.application1.example.com service1 ``` ```text Server3.application1.example.com service2 ``` -------------------------------- ### GET /servers/ Source: https://github.com/yyyar/gobetween/wiki/REST-API Retrieves the definition of a specific server by its name. ```APIDOC ## GET /servers/ ### Description Retrieves the definition of a specific server by its name. ### Method GET ### Endpoint /servers/ ### Parameters #### Path Parameters - **name** (string) - Required - The name of the server. ### Response #### Success Response (200) - **server definition** (object) - The server definition in the same structure as the `[servers.]` entry in the config TOML file, but JSON encoded. #### Response Example ```json { // server definition of the same structure and format as `[servers.]` // entry in config TOML file but JSON encoded. } ``` ``` -------------------------------- ### Complete gobetween configuration with static balancing and health check Source: https://github.com/yyyar/gobetween/wiki/Static-balancing Final configuration combining server settings, static discovery, and health check. Uses round-robin balancing, listens on localhost:3000, and includes a ping health check with 1 failure and 1 success thresholds. ```toml [servers.sample] bind = "localhost:3000" protocol = "tcp" balance = "roundrobin" max_connections = 10000 client_idle_timeout = "10m" backend_idle_timeout = "10m" backend_connection_timeout = "2s" [servers.sample.discovery] kind = "static" static_list = [ "10.0.0.2:22399 weight=5", "10.0.0.3:22499 weight=3", "10.0.0.5:32399 weight=1" ] [servers.sample.healthcheck] fails = 1 passes = 1 interval = "2s" timeout="1s" kind = "ping" ping_timeout_duration = "500ms" ``` -------------------------------- ### GET /ping Source: https://github.com/yyyar/gobetween/wiki/REST-API Health check endpoint that returns a simple OK response. ```APIDOC ## GET /ping ### Description Health check endpoint that returns a simple OK response. ### Method GET ### Endpoint /ping ### Response #### Success Response (200) - **body** (string) - The string "OK". #### Response Example ```json "OK" ``` ``` -------------------------------- ### Download gobetween Linux binary for x86 Source: https://github.com/yyyar/gobetween/wiki/Installation Downloads the latest Linux 386-bit binary release from GitHub using the GitHub API and wget. ```bash curl -s https://api.github.com/repos/yyyar/gobetween/releases | grep browser_download_url | grep linux_386 | cut -d '"' -f 4 | head -n 1 | wget -i - ``` -------------------------------- ### Uninstall gobetween from sources Source: https://github.com/yyyar/gobetween/wiki/Installation Removes gobetween installed from source using make uninstall. ```bash sudo make uninstall ``` -------------------------------- ### Configure UDP protocol with limits and transparent mode Source: https://github.com/yyyar/gobetween/wiki/Protocols Configures a gobetween server to use UDP. Optional settings include max_requests, max_responses, and transparent mode. Note that transparent mode does not work on Windows and requires additional host configuration. ```toml [servers.default] protocol = "udp" [servers.default.udp] # (optional) max_requests = 0 # (optional) if > 0 accepts no more requests than max_requests and closes session (since 0.5.0) max_responses = 0 # (required) if > 0 accepts no more responses that max_responses from backend and closes session (will be optional since 0.5.0) transparent = false # (optional) [NOTE: does not work for Windows] if true - work in transparent mode, when forwarded udp packets have client source address (requires additional host configuration) (since 0.8.0) ``` -------------------------------- ### Discovery script output Source: https://github.com/yyyar/gobetween/wiki/ElasticSearch-cluster-with-Exec-discovery Example output of the discovery script, listing data node addresses in the format IP:9200. ```plaintext 10.0.0.51:9200 10.0.0.55:9200 10.0.0.53:9200 10.0.0.52:9200 10.0.0.54:9200 etc …. ``` -------------------------------- ### Run gobetween on Windows Source: https://github.com/yyyar/gobetween/wiki/Installation Runs gobetween on Windows with a specified configuration file. ```bash c:\path\to\gobetween -c c:\path\to\gobetween.toml ``` -------------------------------- ### Windows exec_command configuration with single quotes Source: https://github.com/yyyar/gobetween/wiki/Windows-specific-notes Example of exec_command configuration for Windows, using single quotes for paths as required. ```toml exec_command = 'C:\gobetween\scripts\healthchecks\exec_healthcheck.bat' exec_command = ['C:\gobetween\scripts\discovery\exec_discovery.bat', 'arg1', 'arg2'] ``` -------------------------------- ### Create Consul config directories Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator Creates the Consul configuration directories for bootstrap, server, and client modes. ```bash #mkdir -p /etc/consul.d/{bootstrap,server,client} ``` -------------------------------- ### GET /servers//stats Source: https://github.com/yyyar/gobetween/wiki/REST-API Retrieves statistics for a specific server, including connection counts, traffic, and backend details. ```APIDOC ## GET /servers//stats ### Description Retrieves statistics for a specific server, including connection counts, traffic, and backend details. ### Method GET ### Endpoint /servers//stats ### Parameters #### Path Parameters - **name** (string) - Required - The name of the server. ### Response #### Success Response (200) - **active_connections** (integer) - Number of active connections. - **rx_total** (integer) - Total bytes received. - **tx_total** (integer) - Total bytes transmitted. - **rx_second** (integer) - Bytes received per second. - **tx_second** (integer) - Bytes transmitted per second. - **backends** (array) - List of backend statistics. - **host** (string) - Backend host. - **port** (string) - Backend port. - **priority** (integer) - Backend priority. - **weight** (integer) - Backend weight. - **stats** (object) - Backend statistics. - **live** (boolean) - Whether the backend is live. - **discovered** (boolean) - Whether the backend was discovered. - **total_connections** (integer) - Total connections to this backend. - **active_connections** (integer) - Active connections to this backend. - **refused_connections** (integer) - Refused connections. - **rx** (integer) - Bytes received. - **tx** (integer) - Bytes transmitted. - **rx_second** (integer) - Bytes received per second. - **tx_second** (integer) - Bytes transmitted per second. #### Response Example ```json { "active_connections": 10, "rx_total": 1024, "tx_total": 2048, "rx_second": 100, "tx_second": 200, "backends": [ { "host": "backend1", "port": "8080", "priority": 1, "weight": 1, "stats": { "live": true, "discovered": false, "total_connections": 100, "active_connections": 5, "refused_connections": 0, "rx": 512, "tx": 1024, "rx_second": 50, "tx_second": 100 } } ] } ``` ``` -------------------------------- ### GET /ping - Ping healthcheck response Source: https://github.com/yyyar/gobetween/wiki/REST-API Response body for the ping endpoint, which returns the string "OK" to indicate the service is healthy. ```js "OK" ``` -------------------------------- ### Download gobetween Linux binary for amd64 Source: https://github.com/yyyar/gobetween/wiki/Installation Downloads the latest Linux amd64 binary release from GitHub using the GitHub API and wget. ```bash curl -s https://api.github.com/repos/yyyar/gobetween/releases | grep browser_download_url | grep linux_amd64 | cut -d '"' -f 4 | head -n 1 | wget -i - ``` -------------------------------- ### GET /dump - Response format Source: https://github.com/yyyar/gobetween/wiki/REST-API Response body for the dump endpoint, which returns the current configuration in TOML or JSON format depending on the 'format' query parameter. ```text # TOML or JSON formatted current config ``` -------------------------------- ### Gobetween static discovery configuration for Consul cluster Source: https://github.com/yyyar/gobetween/wiki/Service-balancing-with-Consul-discovery-and-Docker-Registrator TOML configuration for a gobetween server named 'sample' that listens on 10.0.1.5:8500, uses roundrobin balancing, and static discovery with three Consul nodes. Includes healthcheck settings. ```toml [servers.sample] bind = "10.0.1.5:8500" protocol = "tcp" balance = "roundrobin" max_connections = 100 client_idle_timeout = "10m" backend_idle_timeout = "10m" backend_connection_timeout = "5s" [servers.sample.discovery] kind = "static" static_list = [ "10.0.0.11:8500 weight=1", "10.0.0.12:8500 weight=1", "10.0.0.13:8500 weight=1" ] [servers.sample.healthcheck] fails = 1 passes = 1 interval = "2s" timeout="1s" kind = "ping" ping_timeout_duration = "500ms" ``` -------------------------------- ### Gobetween configuration Source: https://github.com/yyyar/gobetween/wiki/Performance-tests Configuration for gobetween load balancer with TCP protocol, weight balancing, Docker discovery, and health checks. ```ini [logging] level = "info" output = "stdout" [globals] [defaults] max_connections = 0 client_idle_timeout = "30s" backend_idle_timeout = "30s" backend_connection_timeout = "30s" [servers] [servers.sample3] bind = "$ip:80" protocol = "tcp" balance = "weight" [servers.sample3.healthcheck] timeout = "5s" kind = "exec" interval = "7s" exec_command = "./exec_healthcheck.sh" exec_expected_positive_output = "1" exec_expected_negative_output = "0" exec_expected_output = "1" exec_timeout_duration = "2s" [servers.sample3.discovery] kind = "docker" docker_endpoint = "http://127.0.0.1:2375" docker_container_label = "proxied=true" docker_container_private_port = 80 docker_cache_ttl = "20s" ``` -------------------------------- ### Exec discovery configuration Source: https://github.com/yyyar/gobetween/wiki/Discovery Configuration for exec discovery. Set kind to "exec" and provide the required exec_command array with the program path and optional arguments. ```toml [servers.example] # ... [servers.example.discovery] kind = "exec" exec_command = ["/path/to/script.sh", "arg1", "arg2"] # (required) command to exec and variable-length arguments ``` -------------------------------- ### Backend pool with max_connections Source: https://github.com/yyyar/gobetween/wiki/Balancing Example of a backend pool with max_connections property to limit active connections per backend. After reaching the limit, the backend is not used until connections drop below the limit. ```json [ "host1 weight=1 priority=1 max_connections=10" "host2 weight=2 priority=1" ] ``` -------------------------------- ### POST /servers/ Source: https://github.com/yyyar/gobetween/wiki/REST-API Creates a new server with the specified name. ```APIDOC ## POST /servers/ ### Description Creates a new server with the specified name. ### Method POST ### Endpoint /servers/ ### Parameters #### Path Parameters - **name** (string) - Required - The name of the server to create. #### Request Body - **server definition** (object) - Required - The server definition in the same structure as the `[servers.]` entry in the config TOML file, but JSON encoded. ### Request Example ```json { // server definition of the same structure and format as `[servers.]` // entry in config TOML file but JSON encoded. } ``` ### Response #### Success Response (200) No specific response body documented. ```