Skip to content

Xray-core — Config Layout

Xray-core reads a single JSON document at startup. The root object maps directly to Go struct Config at infra/conf/xray.go:346. Every top-level field below corresponds to one JSON key.

Root keys

KeyGo fieldTypePageDescription
logLogConfigLogConfigLogAccess and error log streams, level, DNS-query logging, IP masking.
dnsDNSConfigDNSConfigDNSPhase 5DNS resolver, server list, query strategy, fakedns linkage.
routingRouterConfigRouterConfigRoutingPhase 5Domain strategy, rules, balancers.
inboundsInboundConfigs[]InboundDetourConfigInboundsPhase 3List of listening services.
outboundsOutboundConfigs[]OutboundDetourConfigOutboundsPhase 3List of upstream proxy targets.
policyPolicyPolicyConfigPolicyPer-level timeouts, buffer size, user-stats toggles, system-stats toggles.
apiAPIAPIConfigAPIgRPC management API inbound (tag + listen + service list).
statsStatsStatsConfigStatsEmpty struct; presence enables the stats subsystem.
metricsMetricsMetricsConfigMetricsPrometheus exporter (tag + listen).
reverseReverseReverseConfigReverseReverse-proxy bridges and portals.
fakeDnsFakeDNSFakeDNSConfigFakeDNSFake-IP pool config (single object or array).
observatoryObservatoryObservatoryConfigObservatoryOutbound latency probing.
burstObservatoryBurstObservatoryBurstObservatoryConfigBurst ObservatoryConcurrent latency probing with health-check tuning.
versionVersionVersionConfigVersionOptional min/max version requirement.
transportTransportmap[string]json.RawMessageDeprecatedKept only to surface a friendly error if a legacy config carries it.

Pages marked Phase 3/5 ship in those later phases; the column is here so the layout is complete today.

At a glance

json
{
  "log": { "loglevel": "warning" },
  "dns": {},
  "routing": { "rules": [] },
  "inbounds": [],
  "outbounds": [],
  "policy": { "levels": { "0": { "handshake": 4 } } },
  "api": { "tag": "api", "listen": "127.0.0.1:10085", "services": ["HandlerService", "StatsService"] },
  "stats": {},
  "metrics": { "tag": "metrics", "listen": "127.0.0.1:9099" }
}

Source: infra/conf/xray.go:346-365 · v1.260327.0 (d2758a0)

Core Tutorial by Argsment