Xray-examples icon indicating copy to clipboard operation
Xray-examples copied to clipboard

Trojan-gRPC-Caddy2 提示 failed to find an available destination

Open wutea7 opened this issue 3 years ago • 0 comments
trafficstars

server log
Xray 1.6.0 (Xray, Penetrates Everything.) Custom (go1.19.1 linux/amd64)
A unified platform for anti-censorship.
2022/10/08 22:54:11 [Info] infra/conf/serial: Reading config: /usr/local/etc/xray/config.json
2022/10/08 22:54:12 [Warning] core: Xray 1.6.0 started

client log
Xray 1.6.0 (Xray, Penetrates Everything.) Custom (go1.19.1 darwin/arm64)
A unified platform for anti-censorship.
2022/10/08 22:54:13 [Info] infra/conf/serial: Reading config: /opt/homebrew/etc/xray/config.json
2022/10/08 22:54:13 [Warning] core: Xray 1.6.0 started
2022/10/08 22:54:18 tcp:127.0.0.1:64224 accepted tcp:alive.github.com:443 [Trojan_grpc_in -> Trojan_grpc_out]
2022/10/08 22:54:21 [Warning] [4095847556] app/proxyman/outbound: failed to process outbound traffic > proxy/trojan: failed to find an available destination > common/retry: [transport/internet/grpc: failed to dial gRPC > transport/internet/grpc: Cannot dial gRPC > rpc error: code = Unavailable desc = connection closed before server preface received] > common/retry: all retry attempts failed
2022/10/08 22:54:23 tcp:127.0.0.1:64263 accepted tcp:www.google.com:443 [Trojan_grpc_in -> Trojan_grpc_out]
2022/10/08 22:54:25 [Warning] [3760251225] app/proxyman/outbound: failed to process outbound traffic > proxy/trojan: failed to find an available destination > common/retry: [transport/internet/grpc: failed to dial gRPC > transport/internet/grpc: Cannot dial gRPC > rpc error: code = Unavailable desc = connection closed before server preface received] > common/retry: all retry attempts failed

Caddyfile
{
    order reverse_proxy before route
    admin off
    log {
        output file /var/log/caddy/access.log
        level ERROR
    }
}

domain.com {
    tls {
        protocols tls1.3
        ciphers TLS_AES_256_GCM_SHA384 TLS_AES_128_GCM_SHA256 TLS_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
        curves x25519 secp521r1 secp384r1 secp256r1
        alpn http/1.1 h2
    }

    @websocket {
        header Connection *Upgrade*
        header Upgrade websocket
        path /JupIOuLQu
    }
    reverse_proxy @websocket localhost:6668

    @grpc {
        protocol grpc
        path /ZhrDqzeQv/*
    }
    reverse_proxy @grpc localhost:6667

    @host {
        host domain.com
    }
    route @host {
        encode gzip
        header {
            Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
        }
        file_server {
            root /usr/share/caddy
        }
    }
}

server.json
{
    "log": {
        "loglevel": "warning"
    },
    "dns": {
        "hosts": { "dns.google": "8.8.8.8" },
        "servers": [
            "https://1.1.1.1/dns-query",
            "https://dns.google/dns-query",
            "1.1.1.1",
            "8.8.8.8"
        ]
    },
    "inbounds": [
        {
            "tag": "Trojan_grpc",
            "listen": "127.0.0.1",
            "port": 6667,
            "protocol": "trojan",
            "settings": {
                "clients": [
                    {
                        "password": "password"
                    }
                ]
            },
            "streamSettings": {
                "network": "grpc",
                "grpcSettings": { "serviceName": "ZhrDqzeQv" }
            },
            "sniffing": {
                "enabled": true,
                "destOverride": [ "http", "tls" ]
            }
        }
    ],
    "outbounds": [
        {
            "tag": "freedom_out",
            "protocol": "freedom",
            "settings": {
                "domainStrategy": "UseIP"
            }
        },
        {
            "tag": "Blackhole_out",
            "protocol": "blackhole"
        }
    ],
    "routing": {
        "domainStrategy": "AsIs",
        "rules": [
            {
                "type": "field",
                "ip": ["geoip:private"],
                "outboundTag": "Blackhole_out"
            },
            {
                "type": "field",
                "protocol": ["bittorrent"],
                "outboundTag": "Blackhole_out"
            }
        ]
    }
}

client.json
{
    "log":{
        "loglevel": "warning"
    },

    "inbounds": [
        {
            "tag": "Trojan_grpc_in",
            "listen": "127.0.0.1",
            "port": 1086,
            "protocol": "socks"
        }
    ],
    "outbounds": [
        {
            "tag": "Trojan_grpc_out",
            "protocol": "trojan",
            "settings": {
                "servers": [
                    {
                        "address": "domain.com",
                        "port": 443,
                        "password": "password"
                    }
                ]
            },
            "streamSettings": {
                "network": "grpc",
                "security": "tls",
                "grpcSettings": { "serviceName": "ZhrDqzeQv" }
            }
        }
    ],
    "routing": {
        "domainStrategy": "AsIs",
        "rules": [
            {
                "type": "field",
                "inboundTag": "Trojan_grpc_in",
                "outboundTag": "Trojan_grpc_out"
            }
        ]
    }
}

wutea7 avatar Oct 08 '22 15:10 wutea7