Skip to content

Environment

This page lists environment variables read by the Ruby app, Docker runtime image, and embedded NATS entrypoint. Use it as a reference after choosing the role, topology, and traffic pattern.

VariableDefaultApplies toRequired whenDescriptionExample
SERVICE_ROLEreceiver if UPSTREAM_URL is set, else requesterbothNoRuntime role. Must be requester or receiver when set.requester
SERVICE_IDsrv-<random>bothNoInstance identifier used in NATS subjects and observability output. Set a stable, unique value for every live requester and receiver instance.requester-a
UPSTREAM_URLunsetreceiverReceiver-side HTTP forwardingBase URL used by http_request handling when the requester sends origin-form paths. TCP tunnels do not require it.http://app:8080
PORT7000 in Docker imagebothNoRack/Falcon bind port used by the runtime image CMD.7000
APP_ENVunsetbothNoWhen set to test, disables the async warmup hook in config.ru.test
RACK_ENVproduction in Docker imagebothNoRack environment.production
SERVER_ENVproduction in Docker imagebothNoRuntime environment marker from the deploy image.production
RUBY_YJIT_ENABLE1 in Docker imagebothNoEnables Ruby YJIT in the deploy image.1
VariableDefaultApplies toRequired whenDescriptionExample
NATS_URLnats://localhost:4222bothNoNATS server URL used by the Ruby app process.nats://127.0.0.1:4222
NATS_MODEautobothNoBackend mode: core, jetstream, or auto.jetstream
NATS_STREAMproxybothJetStream modeJetStream stream used by pull consumers and JetStream publishes.proxy
NATS_CONSUMER_NAMEnats-proxybothNoBase durable consumer name. JetStream receiver replicas that share work use the same base request consumer; requester response/session consumers add service-specific suffixes.nats-proxy
NATS_QUEUE_GROUPvalue of NATS_CONSUMER_NAMEreceiverCore NATS modeQueue group for the receiver request subscription. Core receiver replicas that share work use the same value.receivers
NATS_REQUEST_SUBJECT_ROOTto.proxybothNoRoot for request, upstream session, HTTP response credit, and cancel subjects.to.proxy
NATS_RESPONSE_SUBJECT_ROOTfrom.proxybothNoRoot for response and downstream session subjects.from.proxy
LISTEN_SUBJECT<request_root>.requests.>receiverNoReceiver subscription filter for bridge request envelopes. Receiver replicas in the same pool use the same value.to.proxy.requests.>
NATS_JS_API_PREFIX$JS.API, or resolved from embedded NATS domainbothNoJetStream API prefix. Embedded mode exports the resolved value after starting nats-server.$JS.DOMAIN.API
  • NATS balances only initial request envelopes and session-open envelopes.
  • After the receiver owner is selected, response events, tunnel bytes, and cancellation are routed by SERVICE_ID.
  • Keep each live SERVICE_ID unique. Share NATS_QUEUE_GROUP in Core NATS or the base NATS_CONSUMER_NAME in JetStream only for receiver replicas that should divide new work.
VariableDefaultApplies toRequired whenDescriptionExample
NATS_RESPONSE_TIMEOUT30requesterNoTimeout waiting for response_start or session_established.30
STREAM_RESPONSE_TIMEOUT30bothNoTimeout for waiting on streaming response events and for flow-credit waits in HTTP streams and TCP tunnels. Idle TCP tunnels are not closed only because no data frames arrive.30
RECEIVER_MAX_INFLIGHT20receiverNoReceiver dispatch concurrency. Internal queue size is twice this value.20

HTTP forwarding has no fixed total-duration limit. Native HTTP socket I/O waits use the hardcoded HttpGateway::HTTP_READ_TIMEOUT of 300 seconds for both transports, independently of the environment variables above. Receiving data allows the next read to wait again. NATS_RESPONSE_TIMEOUT still limits the first response event or tunnel establishment, and response-event and flow-credit waits retain their existing limits. A model that sends no data can still time out; a live connection alone does not extend an I/O wait.

VariableDefaultApplies toRequired whenDescriptionExample
PROXY_AUTH_ENABLEDtruerequesterNoEnables proxy auth for proxy-specific ingress. Set exactly false to disable.true
PROXY_AUTH_USERS_JSONunsetrequesterProxy auth is enabledJSON object of username to bcrypt hash. Missing or invalid value triggers the safety lock.{"alice":"$2a$12$..."}
SOCKS5_ENABLEDfalserequesterNoStarts the requester SOCKS5 listener when true.true
SOCKS5_LISTEN_HOST0.0.0.0requesterNoSOCKS5 bind host.0.0.0.0
SOCKS5_LISTEN_PORT1080requesterNoSOCKS5 bind port.1080

These variables are read by docker/ruby/entrypoint.sh before the Ruby app starts.

VariableDefaultApplies toRequired whenDescriptionExample
EMBEDDED_NATS_ENABLEDfalsebothNoStarts embedded nats-server before the Rack app.true
EMBEDDED_NATS_CONFIGemptybothEmbedded NATS enabled without generated configStatic NATS config path./data/nats.conf
EMBEDDED_NATS_GENERATE_CONFIGfalsebothEmbedded NATS enabled without static configGenerates a NATS config to EMBEDDED_NATS_GENERATED_CONFIG_PATH.true
EMBEDDED_NATS_GENERATED_CONFIG_PATH/data/nats.confbothNoGenerated config path./data/nats.conf
EMBEDDED_NATS_JETSTREAM_ENABLEDreceiver true, requester false when emptybothNoControls whether generated config includes a jetstream block.true
EMBEDDED_NATS_JETSTREAM_STORE_DIR/databothNoFile store directory for embedded JetStream./data
EMBEDDED_NATS_JS_DOMAINemptybothNoOptional JetStream domain in generated config and JS API prefix resolution.EDGE
EMBEDDED_NATS_READY_RETRIES40embeddedNoAttempts for nats rtt readiness before stream bootstrap fails.40
EMBEDDED_NATS_READY_SLEEP_SEC1embeddedNoSleep between embedded NATS readiness attempts.1

Generated embedded config always includes a leafnode listener. In requester role, generated config also requires a remote leafnode target.

VariableDefaultApplies toRequired whenDescriptionExample
EMBEDDED_NATS_LEAF_LISTEN_HOST0.0.0.0bothNoLeafnode listener host in generated config.0.0.0.0
EMBEDDED_NATS_LEAF_LISTEN_PORT7422bothNoLeafnode listener port in generated config.7422
EMBEDDED_NATS_LEAF_USERgenerated or reused from existing configbothIf paired password is setLeaf listener username. If absent, generated config creates or reuses one.leaf_user
EMBEDDED_NATS_LEAF_PASSWORDgenerated or reused from existing configbothIf paired user is setLeaf listener password. Must be paired with user if set manually.secret
LEAF_REMOTE_HOSTemptyrequesterRequester embedded generated configReceiver leafnode host for requester remotes.receiver.example.com
LEAF_REMOTE_PORT7422requesterNoReceiver leafnode port.7422
LEAF_REMOTE_USERemptyrequesterUnless using LEAF_REMOTE_NKEYUsername for requester to connect to receiver leafnode.leaf_user
LEAF_REMOTE_PASSWORDemptyrequesterUnless using LEAF_REMOTE_NKEYPassword for requester leaf remote.secret
LEAF_REMOTE_NKEYemptyrequesterAlternative to user/passwordNKey auth for requester leaf remote. Cannot be combined with user/password.UD...