imgk / caddy-trojan

Caddy module for trojan proxy
GNU General Public License v3.0
204 stars 46 forks source link

剛xcaddy build的版本無法使用? #24

Closed eamlinux closed 2 years ago

eamlinux commented 2 years ago

caddy version:

v2.5.0 h1:eRHzZ4l3X6Ag3kUt8nj5IxATprhqKq/wToP7OHlXWA0=

caddy list-modules:

  Standard modules: 95

admin.api.trojan
caddy.listeners.trojan
http.handlers.trojan
trojan
trojan.proxies.env_proxy
trojan.proxies.no_proxy
trojan.upstreams.caddy
trojan.upstreams.memory

  Non-standard modules: 8

  Unknown modules: 0

以下兩配置trojan均無法使用:

配置1:

{
  order trojan before map
  admin off
  log {
    output discard
  }
  servers :443 {
    listener_wrappers {
      trojan
    }
    protocol {
      allow_h2c
      experimental_http3
    }
  }
  trojan {
    caddy
    no_proxy
    users password1 password2
  }
}

:443, xx.yy {
  encode {
    gzip 6
  }

  tls {
    protocols tls1.3
    curves x25519
    alpn h2
  }

  @host {
    host xx.yy
  }

  route @host {
    trojan {
      connect_method
      websocket
    }
    header {
      Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
      X-Content-Type-Options nosniff
      X-Frame-Options SAMEORIGIN
      Referrer-Policy no-referrer-when-downgrade
    }
    file_server {
      root /var/www/html
    }
  }
}

配置2:

{
  "admin": {"disabled": true},
  "logging": {
    "logs": {
      "default": {
        "writer": {"output":"discard"}
      }
    }
  },
  "apps": {
    "http": {
      "servers": {
        "srv0": {
          "listen": [":443"],
          "listener_wrappers": [{"wrapper": "trojan"}],
          "routes": [{
            "handle": [{
              "encodings": {"gzip": {"level": 6}},
              "handler": "encode",
              "prefer": ["gzip"]
            }]
          },
          {
            "handle": [{
              "handler": "trojan",
              "connect_method": false,
              "websocket": false
            }]
          },
          {
            "match": [{"host": ["xx.yy"]}],
            "handle": [{
              "handler": "subroute",
              "routes": [{
                "handle": [{
                  "handler": "headers",
                  "response": {
                    "set": {
                      "Referrer-Policy": ["no-referrer-when-downgrade"],
                      "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"],
                      "X-Content-Type-Options": ["nosniff"],
                      "X-Frame-Options": ["SAMEORIGIN"]
                    }
                  }
                }]
              },
              {
                "handle": [{
                  "handler": "file_server",
                  "root": "/var/www/html"
                }]
              }]
            }]
          }],
          "tls_connection_policies": [{
            "curves": ["x25519"],
            "alpn": ["h2"],
            "protocol_min": "tls1.3"
          }],
          "experimental_http3": true,
          "allow_h2c": true
        }
      }
    },
    "trojan": {
      "upstream": {
        "upstream": "caddy"
      },
      "proxy": {
        "proxy": "no_proxy"
      },
      "users": ["password1", "password2"]
    },
    "tls": {
      "certificates": {
        "automate": ["xx.yy"]
      }
    }
  }
}
yfsmth commented 2 years ago

我的也是,错误信息: {"level":"error","ts":1651072062.8276677,"logger":"caddy.listeners.trojan","msg":"read prefix error: read tcp 114.250.230.xxx:17711 -> 104.194.247.xxx:443: read: EOF"}

imgk commented 2 years ago

Fixed