Skip to content

Xray configuration (AsteriskNG) ​

AsteriskNG does not ask you to edit a full Xray config file. Instead, it generates an Xray JSON configuration on every start from the servers, routing rules, and settings in the UI. Knowing how that works helps you write correct routing rules, or use your own Xray config in a Custom server.

Structure of the generated config ​

Xray fieldSource
logLog level, Record access logs
inboundsThe current run mode and Local proxy settings (see below)
outboundsThe selected server / strategy group / proxy chain, plus the fixed direct, block, and similar outbounds
routingRules on the Routing page, the Default outbound proxy tag, and the Domain strategy
dns, fakeDnsCore settings → DNS settings
observatory, burstObservatoryGenerated automatically for "Least ping" and "Least Load" strategy groups
stats, api, policyAdded when Show traffic statistics is on, for traffic statistics

Reserved tags ​

These tags are reserved by the app and can be referenced from routing rules or Custom configs:

TagKindNotes
proxyOutboundThe currently selected server
directOutboundfreedom direct connection
blockOutboundblackhole
dns-outOutboundDNS outbound used for DNS hijacking
fragmentOutboundfreedom fragment outbound when Fragment is on
dns-proxy / dns-directInternalTags used for proxy DNS / direct DNS queries

Inbounds and run modes ​

Inbound tagWhen present
vpn-tun-inXray's tun inbound in VPN Service mode with Use Hev TUN off
asterisk-bridgeReceives traffic with app ownership information in VPN Service with Use Hev TUN on, and in TUN2SOCKS and BPF2SOCKS modes
socks-inThe local proxy from Local proxy settings
vpn-http-inVPN Service with Append HTTP proxy
tproxy-inTPROXY mode
tun2socks-inAdditional SOCKS inbound generated in TUN2SOCKS mode
bpf2socks-inAdditional SOCKS inbound generated in BPF2SOCKS mode

With DNS hijacking on, the app inserts a rule before the rules from the Routing page to send TCP and UDP traffic to port 53 from the relevant inbounds to dns-out. In VPN Service with Use Hev TUN on, this rule matches both asterisk-bridge and socks-in.

How servers become outbounds ​

In the UIGenerated Xray config
Regular server (VLESS, VMess, Trojan, …)One outbound of that protocol; streamSettings comes from the transport and security settings
Strategy groupA balancer in routing.balancers. strategy.type maps Least ping → leastPing, Least Load → leastLoad, Random → random, Round robin → roundRobin. leastPing adds an observatory and leastLoad adds a burstObservatory for probing
Proxy chainOne outbound per member; each later hop dials through the previous one via streamSettings.sockopt.dialerProxy
FragmentThe server's sockopt.dialerProxy points to the fragment outbound, whose freedom fragment option splits early TCP data by Fragment mode, length, and interval
MuxThe outbound's mux field (concurrency, xudpConcurrency, xudpProxyUDP443)

Writing routing rules ​

Each rule on the Routing page becomes one entry in routing.rules. Rules are matched top to bottom; the first match wins.

Domain rules support all Xray forms:

FormMeaning
example.comSubstring match
domain:example.comThe domain and its subdomains
full:www.example.comExact match
keyword:googleKeyword match
regexp:\.cn$Regular expression
geosite:cnA category from geosite.dat
ext:file.dat:tagA category from a custom dat file in the resource directory

IP rules accept single IPs, CIDRs (e.g. 10.0.0.0/8), geoip:cn, geoip:private, and so on, as well as ext:file.dat:tag.

Custom rule files

A .dat file downloaded with Add custom resource file in Resource management can be referenced with ext:. Before starting, the app checks that every file referenced with ext: in the Domain rules of enabled rules exists and is not empty, and reports an error instead of letting the core silently ignore it.

Custom servers ​

A Custom server lets you paste Xray JSON directly. It must be a JSON object with at least one entry in outbounds.

With "Override inbound and DNS settings" on (default) ​

Use this when you want your own outbounds and routing but let the app handle the rest. The app will:

  • replace inbounds with the current run mode's inbounds, and replace dns and fakeDns with the app's DNS settings;
  • remove your direct and dns-out outbounds and use the app's direct instead, adding the app's dns-out when DNS hijacking is on;
  • treat the outbound tagged proxy as the main outbound; if there is none, use the first outbound without a reserved tag (and name it proxy if it has no tag);
  • insert the DNS hijacking and DNS upstream rules before your routing.rules, keeping your rules in their original order.

With the override off ​

The app keeps your custom inbounds, DNS, and routing. It adds asterisk-bridge in run modes that use that inbound. When Show traffic statistics is on, it also adds stats, api, and policy.

  • Your config must provide the other inbounds, DNS, and routing required by the current run mode. For example, TPROXY needs a dokodemo-door inbound listening on the Transparent proxy port.
  • the app's DNS settings and the rules on the Routing page do not apply to this server; per-app proxy is enforced by the VPN / ROOT layer and still applies.

WARNING

Turning the override off is an advanced option. If the config does not match the run mode, the proxy may start but nothing will load. Keep it on in most cases.

Official documentation ​