Wood Chen

Route Gemini, Chatgpt, and Claude Traffic to Another Server with XrayR and Gost

0 comments174 views510 words

This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文

Background: I use dmit's malibu. Most websites work fine, but gemini always displays "Network error, please try again later", so I wanted to see whether routing its traffic through rn would help.

Setup

  • Server A: The main server running XrayR and handling client traffic. I use dmit.

  • Server B: A secondary server with Gost installed. I use racknerd.

  • Goal: When accessing Gemini or Google, Server A automatically forwards the traffic to Server B, which makes the requests on its behalf to resolve regional restrictions or IP issues.


Step 1: Prepare Server B (Proxy Server)

Run Gost on Server B to provide an HTTP proxy endpoint.

  1. Download the binary from github: https://github.com/ginuerzh/gost/releases/tag/v2.12.0
  2. Extract it into a directory, such as /opt/gost, set the appropriate permissions, then run it under a process supervisor:
/opt/gost/gost -L http://用户名:密码@:28443

The username, password, and port can all be customized ![[Pasted image 20260122144819.png]] 3. Firewall access: Allow access to port 28443 on Server B, but only from Server A for better security.


Step 2: Configure Server A (Traffic Routing Client)

On Server A, we need to tell XrayR: “If you see traffic destined for Google, send it to port 28443 on Server B.”

1. Locate the Configuration Files

First, check the paths for these two settings in /etc/XrayR/config.yml on Server A. The defaults are usually:

  • RouteConfigPath: /etc/XrayR/route.json

  • OutboundConfigPath: /etc/XrayR/custom_outbound.json

If you have not configured them before, they are probably commented out with #. Remove the # to enable the rules.

2. Configure the Custom Outbound (custom_outbound.json)

Edit this file and add Server B's details. Note the tag field, which identifies this outbound in the routing rules.

[
  {
    "tag": "proxy-rn",  #You can customize this name
    "protocol": "http",
    "settings": {
      "servers": [
        {
          "address": "B服务器IP", 
          "port": 28443,
          "users": [
            {
              "user": "czlgost",
              "pass": "wiejasxxxx"
            }
          ]
        }
      ]
    }
  }
]

3. Configure the Routing Rules (route.json)

Edit this file to define the routing logic. To ensure Gemini works reliably, I recommend routing all of geosite:google through the proxy.

Complete example

{
  "domainStrategy": "IPOnDemand",
  "rules": [
    {
      "type": "field",
      "outboundTag": "proxy-rn",
      "domain": [
        "geosite:google",
        "geosite:openai",
        "geosite:anthropic"
      ]
    },
    {
      "type": "field",
      "outboundTag": "block",
      "ip": [
        "geoip:private"
      ]
    },
    {
      "type": "field",
      "outboundTag": "block",
      "protocol": [
        "bittorrent"
      ]
    },
    {
      "type": "field",
      "outboundTag": "IPv4_out",
      "domain": [
        "geosite:cn"
      ]
    },
    {
      "type": "field",
      "outboundTag": "IPv4_out",
      "ip": [
        "geoip:cn"
      ]
    },
    {
      "type": "field",
      "outboundTag": "IPv4_out",
      "network": "udp,tcp"
    }
  ]
}

Step 3: Restart to Apply the Changes

After making the changes, restart the XrayR service on Server A:

Bash

XrayR restart

Step 4: Verify That Traffic Routing Works

1. Check Live Logs (Most Accurate)

Monitor traffic routing on Server A:

Bash

journalctl -u XrayR -f

When you visit gemini.google.com, if the logs show outbound: proxy-gemini, the traffic has been successfully forwarded to Server B.


⚠️ Notes and Common Issues

1. JSON Formatting Pitfalls

JSON syntax is very strict. Make sure all braces { } and brackets [ ] are correctly paired at every level, and do not add a comma after the last item in a list. If restarting fails, it is usually a JSON syntax issue.

2. Missing Resource Files

If the geosite:google rule does not work, check whether geosite.dat exists in /etc/XrayR/. Without it, the routing rule cannot be recognized.

3. Security Reminder

Gost's HTTP proxy protocol transmits data between A and B in plaintext, so this setup is only suitable when both servers are outside mainland China. If Server A is in mainland China, switch to VLESS or Trojan with TLS encryption; otherwise, the traffic will be detected by the firewall.

Related posts

Comments 0