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:391. Every top-level field below corresponds to one JSON key.
Root keys
| Key | Go field | Type | Page | Description |
|---|---|---|---|---|
env | Env | EnvConfig (map[string]string) | — | Environment variables applied via os.Setenv before the rest of the config is built. Merged across multi-file configs (later files override same keys). |
log | LogConfig | LogConfig | Log | Access and error log streams, level, DNS-query logging, IP masking. |
dns | DNSConfig | DNSConfig | DNS | DNS resolver, server list, query strategy, fakedns linkage. |
routing | RouterConfig | RouterConfig | Routing | Domain strategy, rules, balancers. |
inbounds | InboundConfigs | []InboundDetourConfig | Inbounds | List of listening services. |
outbounds | OutboundConfigs | []OutboundDetourConfig | Outbounds | List of upstream proxy targets. |
policy | Policy | PolicyConfig | Policy | Per-level timeouts, buffer size, user-stats toggles, system-stats toggles. |
api | API | APIConfig | API | gRPC management API inbound (tag + listen + service list). |
stats | Stats | StatsConfig | Stats | Empty struct; presence enables the stats subsystem. |
metrics | Metrics | MetricsConfig | Metrics | Prometheus exporter (tag + listen). |
reverse | Reverse | ReverseConfig | Reverse | Reverse-proxy bridges and portals. |
fakeDns | FakeDNS | FakeDNSConfig | FakeDNS | Fake-IP pool config (single object or array). |
observatory | Observatory | ObservatoryConfig | Observatory | Outbound latency probing. |
burstObservatory | BurstObservatory | BurstObservatoryConfig | Burst Observatory | Concurrent latency probing with health-check tuning. |
version | Version | VersionConfig | Version | Optional min/max version requirement. |
transport | Transport | map[string]json.RawMessage | Deprecated | Kept only to surface a friendly error if a legacy config carries it. |
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:391-412 · v26.7.28 (5ca6f4b)
