### Install Dependencies and Run Dev Server Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/document/document.html Install project dependencies and start the local development server to preview documentation changes. ```bash pnpm install pnpm run docs:dev ``` -------------------------------- ### Download Xray Installation Script Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/document/level-0/ch07-xray-server.html Use wget to download the official Xray installation script. This is the first step before executing the installation. ```shell wget https://github.com/XTLS/Xray-install/raw/main/install-release.sh ``` -------------------------------- ### Execute Xray Installation Script Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/document/level-0/ch07-xray-server.html Run the downloaded installation script using bash with sudo privileges. This command installs Xray on the server. ```shell sudo bash install-release.sh ``` -------------------------------- ### Install Nginx Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/document/level-1/fallbacks-with-sni.html Installs Nginx from the official repository. Ensure you have curl, gnupg2, and ca-certificates installed. ```bash sudo apt install curl gnupg2 ca-certificates lsb-release echo "deb [arch=amd64] [http://nginx.org/packages/ubuntu](http://nginx.org/packages/ubuntu) `lsb_release -cs` nginx" \ | sudo tee /etc/apt/sources.list.d/nginx.list curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add - sudo apt update sudo apt install nginx ``` -------------------------------- ### Complete Routing Configuration Example Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/config/routing.html An example demonstrating the integration of routing rules, load balancers, inbounds, and outbounds. ```json { "routing": { "rules": [ { "inboundTag": ["in"], "balancerTag": "round" } ], "balancers": [ { "selector": ["out"], "strategy": { "type": "roundRobin" }, "tag": "round" } ] }, "inbounds": [ { // Inbound config "tag": "in" } ], "outbounds": [ { // Outbound config "tag": "out1" }, { // Outbound config "tag": "out2" } ] } ``` -------------------------------- ### gRPC Reflection Example Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/config/api.html Example command to list available gRPC services using grpcurl. ```APIDOC ## gRPC Reflection Example ### Description This example demonstrates how to use `grpcurl` to list the available gRPC services exposed by the Xray API interface. ### Command ```bash $ grpcurl -plaintext localhost:10085 list ``` ### Output Example ``` grpc.reflection.v1alpha.ServerReflection v2ray.core.app.proxyman.command.HandlerService v2ray.core.app.stats.command.StatsService xray.app.proxyman.command.HandlerService xray.app.stats.command.StatsService ``` ``` -------------------------------- ### Compile and Install Nginx Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/document/level-2/nginx_or_haproxy_tls_tunnel.html Compiles the Nginx source code and installs it to the specified prefix. ```bash make && make install ``` -------------------------------- ### Install Haproxy Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/document/level-2/nginx_or_haproxy_tls_tunnel.md Install Haproxy using your system's package manager. ```bash pacman -Su haproxy ``` ```bash apt install haproxy ``` -------------------------------- ### gRPCurl Example Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/config/api.md Example of using grpcurl to list available APIs on the server. ```APIDOC ```bash $ grpcurl -plaintext localhost:10085 list grpc.reflection.v1alpha.ServerReflection v2ray.core.app.proxyman.command.HandlerService v2ray.core.app.stats.command.StatsService xray.app.proxyman.command.HandlerService xray.app.stats.command.StatsService ``` ``` -------------------------------- ### Start Xray Service Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/document/level-0/ch07-xray-server.md Use this command to start the Xray service. Ensure you have the necessary permissions. ```shell sudo systemctl start xray ``` -------------------------------- ### Install openresolv Package Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/document/level-2/redirect.html This command installs the openresolv package, which is required if the DNS field in the WireGuard '[Interface]' section is used. ```bash apt install openresolv ``` -------------------------------- ### Example: Run Xray client with specific user and config Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/document/level-2/iptables_gid.html This example demonstrates setting the maximum open file limit and then executing the Xray client with a specific user and configuration file. ```bash ulimit -SHn 1000000 sudo -u xray_tproxy xray -c /etc/xray/config.json & ``` -------------------------------- ### Blackhole Outbound Configuration Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/config/outbounds/blackhole.md Example of configuring a Blackhole outbound in the settings. This setup discards all traffic without sending any response. ```json { "outbounds": [ { // ... "protocol": "blackhole", // [!code focus:5] "settings": { "response": { "type": "none" } } } ] } ``` -------------------------------- ### Process Matching Examples Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/config/routing.md Examples for matching traffic based on the process name or path. Supports matching the current core process ('self/') or processes started from the current Xray binary ('xray/'). Path matching is case-sensitive and uses forward slashes. ```text self/ ``` ```text xray/ ``` ```text C:/Windows/System32/curl.exe ``` -------------------------------- ### Example Sockopt Configuration Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/config/transports/sockopt.html This example demonstrates how to configure various socket options within the streamSettings of an outbound configuration. It includes settings for TCP segmentation, fast open, transparent proxying, and more. ```json { "outbounds": [ { "streamSettings": { "sockopt": { "mark": 0, "tcpMaxSeg": 1440, "tcpFastOpen": false, "tproxy": "off", "domainStrategy": "AsIs", "happyEyeballs": {}, "dialerProxy": "", "acceptProxyProtocol": false, "trustedXForwardedFor": [], "tcpKeepAliveInterval": 0, "tcpKeepAliveIdle": 300, "tcpUserTimeout": 10000, "tcpcongestion": "bbr", "interface": "wg0", "V6Only": false, "tcpWindowClamp": 600, "tcpMptcp": false, "addressPortStrategy": "", "customSockopt": [] } } } ] } ``` -------------------------------- ### Upgrade Installed Packages Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/document/level-0/ch03-ssh.html Installs the latest versions of all installed packages. You may be prompted to confirm the installation by typing 'y'. ```shell apt upgrade ``` -------------------------------- ### Merged Configuration Example Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/config/features/multiple.html Illustrates the final merged configuration after applying the rules for overwriting and appending based on the three input files. ```json { "log": { "loglevel": "debug" // Top-level object overwrites the former }, "inbounds": [ { "tag": "socks", // Overwrites the former when tag is the same "protocol": "socks", "listen": "127.0.0.1", "port": 1080 } ], "outbounds": [ { "tag": "block", // outbounds added to the front "protocol": "blackhole" }, { "tag": "direct", "protocol": "freedom" }, { "tag": "direct2", // Filename of 03_tail.json contains 'tail' keyword, added to the end "protocol": "freedom" } ] } ``` -------------------------------- ### Create Web Directory and Index File Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/document/level-0/ch05-webpage.md Use this command to create a directory for your website and open an index.html file for editing. Ensure you understand the '~' symbol's meaning based on your user type (root or non-root). ```shell mkdir -p ~/www/webpage/ && nano ~/www/webpage/index.html ``` -------------------------------- ### Run Xray with Configuration Files Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/document/command.html Use this command to start Xray with specified configuration files. Multiple configuration files can be merged. Supports local files, standard input, and remote URLs. ```bash xray run [-c config.json] [-confdir dir] ``` ```bash xray run -config base.json -config routing.json -config outbounds.yaml ``` ```bash # Read from a local file xray run -config ./config.json # Read from standard input cat config.json | xray run -config stdin: # Read from a remote URL xray run -config https://example.com/xray/config.json # Read through an HTTP endpoint on a Unix Domain Socket xray run -config http+unix:///run/xray-config.sock/config.json ``` ```bash xray run -dump ``` -------------------------------- ### Install Xray via Homebrew on macOS Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/document/install.html Use the Homebrew package manager to install Xray on macOS. Ensure Homebrew is installed first. ```bash brew install xray ``` -------------------------------- ### Install iptables modules on OpenWrt Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/document/level-2/iptables_gid.md Installs necessary iptables modules for transparent proxying on OpenWrt systems. Ensure these are installed if Xray fails to run. ```bash opkg install sudo iptables-mod-tproxy iptables-mod-extra ``` -------------------------------- ### Install Xray via AUR helper on Arch Linux Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/document/install.html Install Xray on Arch Linux using an AUR helper like `yay`. This command assumes `yay` is installed. ```bash yay -S xray ``` -------------------------------- ### Install acme.sh Source: https://github.com/xtls/xtls.github.io/blob/gh-pages-next/en/document/level-0/ch06-certificates.html Use wget to download and execute the acme.sh installation script. ```shell wget -O - https://get.acme.sh | sh ```