Docker swarm drone:0.9-beta gitlab.com webhook return 502

I run drone in docker swarm mode, the docker-compose file like this:

services:
  proxy:
    image: shynome/caddy
    ports: [ '80:80', '443:443' ]
  beta_drone:
    image: drone/drone:0.9.0-alpha.1
    deploy: 
      <<: *drone_deploy
      replicas: 1
      endpoint_mode: dnsrr
    volumes: 
      - /var/run/docker.sock:/var/run/docker.sock
    environment: 
      DRONE_TLS_AUTOCERT: 'false'
      DRONE_GITLAB_SERVER: https://gitlab.com
      DRONE_GITLAB_CLIENT_ID: xxxxx
      DRONE_GITLAB_CLIENT_SECRET: xxxxxxx
      DRONE_SERVER_HOST: beta.drone.company.com
      DRONE_SERVER_PROTO: https
      DRONE_PRIVATE_MODE: 'false'
      DRONE_LOGS_DEBUG: 'true'
      DRONE_RUNNER_CAPACITY: '2'

the caddy file like this

beta.drone.company.com {

  gzip {
    not /stream/
  }

  proxy / beta_drone:80 {
    websocket
    transparent
  }

}

gitlab webhook test details

Request headers:
Content-Type: application/json
X-Gitlab-Event: Push Hook
X-Gitlab-Token: Kbtb3OOA3sskze0SeQsgVrvYCvdP9mgI
Request body:
{
  "object_kind": "push",
  "event_name": "push",
  "before": "036739722271590a9b26aca81e64b67bb7a12731",
  "after": "d36a23c19ac2fdeaf12dd7a9d6e52c1b896a318f",
  "ref": "refs/heads/master",
  "checkout_sha": "d36a23c19ac2fdeaf12dd7a9d6e52c1b896a318f",
  "message": null,
  "user_id": 1903716,
  "user_name": "shynome",
  "user_username": "shynome",
  "user_email": "shynome@gmail.com",
  "user_avatar": "https://secure.gravatar.com/avatar/8e528764c107dad1e45b8c98fa691806?s=80&d=identicon",
  "project_id": 8165265,
  "project": {
    "id": 8165265,
    "name": "drone-test",
    "description": "",
    "web_url": "https://gitlab.com/shynome/drone-test",
    "avatar_url": null,
    "git_ssh_url": "git@gitlab.com:shynome/drone-test.git",
    "git_http_url": "https://gitlab.com/shynome/drone-test.git",
    "namespace": "shynome",
    "visibility_level": 0,
    "path_with_namespace": "shynome/drone-test",
    "default_branch": "master",
    "ci_config_path": null,
    "homepage": "https://gitlab.com/shynome/drone-test",
    "url": "git@gitlab.com:shynome/drone-test.git",
    "ssh_url": "git@gitlab.com:shynome/drone-test.git",
    "http_url": "https://gitlab.com/shynome/drone-test.git"
  },
  "commits": [
    {
      "id": "d36a23c19ac2fdeaf12dd7a9d6e52c1b896a318f",
      "message": "sss\n",
      "timestamp": "2018-09-11T08:36:41Z",
      "url": "https://gitlab.com/shynome/drone-test/commit/d36a23c19ac2fdeaf12dd7a9d6e52c1b896a318f",
      "author": {
        "name": "shynome",
        "email": "shynome@gmail.com"
      },
      "added": [

      ],
      "modified": [
        ".drone.yml"
      ],
      "removed": [

      ]
    },
    {
      "id": "3cee86e9ebce619ec9ccd8e6c00f58a50b04435a",
      "message": "ss\n",
      "timestamp": "2018-08-31T06:29:50Z",
      "url": "https://gitlab.com/shynome/drone-test/commit/3cee86e9ebce619ec9ccd8e6c00f58a50b04435a",
      "author": {
        "name": "shynome",
        "email": "shynome@gmail.com"
      },
      "added": [

      ],
      "modified": [
        ".drone.yml"
      ],
      "removed": [

      ]
    },
    {
      "id": "036739722271590a9b26aca81e64b67bb7a12731",
      "message": "a\n",
      "timestamp": "2018-08-31T06:18:56Z",
      "url": "https://gitlab.com/shynome/drone-test/commit/036739722271590a9b26aca81e64b67bb7a12731",
      "author": {
        "name": "shynome",
        "email": "shynome@gmail.com"
      },
      "added": [

      ],
      "modified": [
        ".drone.yml"
      ],
      "removed": [

      ]
    }
  ],
  "total_commits_count": 3,
  "repository": {
    "name": "drone-test",
    "url": "git@gitlab.com:shynome/drone-test.git",
    "description": "",
    "homepage": "https://gitlab.com/shynome/drone-test",
    "git_http_url": "https://gitlab.com/shynome/drone-test.git",
    "git_ssh_url": "git@gitlab.com:shynome/drone-test.git",
    "visibility_level": 0
  }
}
Response headers:
Content-Type: text/plain; charset=utf-8
Server: Caddy
X-Content-Type-Options: nosniff
Date: Tue, 11 Sep 2018 09:00:20 GMT
Content-Length: 16
Connection: close
Response body:
502 Bad Gateway

drone debugger logout

2018/09/11 09:00:20 http: panic serving 10.0.3.4:60252: runtime error: invalid memory address or nil pointer dereference
goroutine 364 [running]:
net/http.(*conn).serve.func1(0xc42009aa00)
        /usr/local/go/src/net/http/server.go:1726 +0xd0
panic(0xc49800, 0x138b0c0)
        /usr/local/go/src/runtime/panic.go:502 +0x229
github.com/drone/drone/internal/scm/hook/parser.(*parser).Parse(0xc4203524d8, 0xc420130f00, 0xc42038abc0, 0x1, 0x1, 0x0, 0x0)
        /go/src/github.com/drone/drone/internal/scm/hook/parser/parse.go:87 +0xba
github.com/drone/drone/internal/web.HandleHook.func1(0xdf3160, 0xc4202e2540, 0xc420130f00)
        /go/src/github.com/drone/drone/internal/web/hook.go:48 +0x102
net/http.HandlerFunc.ServeHTTP(0xc42033d000, 0xdf3160, 0xc4202e2540, 0xc420130f00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).routeHTTP(0xc4203e8ea0, 0xdf3160, 0xc4202e2540, 0xc420130f00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:424 +0x289
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).(github.com/drone/drone/vendor/github.com/go-chi/chi.routeHTTP)-fm(0xdf3160, 0xc4202e2540, 0xc420130f00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:368 +0x48
net/http.HandlerFunc.ServeHTTP(0xc42045d610, 0xdf3160, 0xc4202e2540, 0xc420130f00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).ServeHTTP(0xc4203e8ea0, 0xdf3160, 0xc4202e2540, 0xc420130f00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:69 +0x2eb
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).Mount.func1(0xdf3160, 0xc4202e2540, 0xc420130f00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:291 +0x107
net/http.HandlerFunc.ServeHTTP(0xc4203bb9c0, 0xdf3160, 0xc4202e2540, 0xc420130f00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).routeHTTP(0xc4203e8de0, 0xdf3160, 0xc4202e2540, 0xc420130f00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:424 +0x289
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).(github.com/drone/drone/vendor/github.com/go-chi/chi.routeHTTP)-fm(0xdf3160, 0xc4202e2540, 0xc420130f00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:368 +0x48
net/http.HandlerFunc.ServeHTTP(0xc42045d620, 0xdf3160, 0xc4202e2540, 0xc420130f00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/rs/zerolog/hlog.RequestIDHandler.func1.1(0xdf3160, 0xc4202e2540, 0xc420130f00)
        /go/src/github.com/drone/drone/vendor/github.com/rs/zerolog/hlog/hlog.go:164 +0x149
net/http.HandlerFunc.ServeHTTP(0xc42033d080, 0xdf3160, 0xc4202e2540, 0xc420130e00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/rs/zerolog/hlog.MethodHandler.func1.1(0xdf3160, 0xc4202e2540, 0xc420130e00)
        /go/src/github.com/drone/drone/vendor/github.com/rs/zerolog/hlog/hlog.go:58 +0xf5
net/http.HandlerFunc.ServeHTTP(0xc42048b380, 0xdf3160, 0xc4202e2540, 0xc420130e00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/rs/zerolog/hlog.URLHandler.func1.1(0xdf3160, 0xc4202e2540, 0xc420130e00)
        /go/src/github.com/drone/drone/vendor/github.com/rs/zerolog/hlog/hlog.go:44 +0xf5
net/http.HandlerFunc.ServeHTTP(0xc42048b3b0, 0xdf3160, 0xc4202e2540, 0xc420130e00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/rs/zerolog/hlog.RemoteAddrHandler.func1.1(0xdf3160, 0xc4202e2540, 0xc420130e00)
        /go/src/github.com/drone/drone/vendor/github.com/rs/zerolog/hlog/hlog.go:88 +0xc6
net/http.HandlerFunc.ServeHTTP(0xc42048b3e0, 0xdf3160, 0xc4202e2540, 0xc420130e00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/rs/zerolog/hlog.NewHandler.func1.1(0xdf3160, 0xc4202e2540, 0xc420130c00)
        /go/src/github.com/drone/drone/vendor/github.com/rs/zerolog/hlog/hlog.go:30 +0x39d
net/http.HandlerFunc.ServeHTTP(0xc42041d9d0, 0xdf3160, 0xc4202e2540, 0xc420130c00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi/middleware.NoCache.func1(0xdf3160, 0xc4202e2540, 0xc420130c00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/middleware/nocache.go:54 +0x217
net/http.HandlerFunc.ServeHTTP(0xc4203bb9e0, 0xdf3160, 0xc4202e2540, 0xc420130c00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).ServeHTTP(0xc4203e8de0, 0xdf3160, 0xc4202e2540, 0xc420130c00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:69 +0x2eb
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).Mount.func1(0xdf3160, 0xc4202e2540, 0xc420130c00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:291 +0x107
net/http.HandlerFunc.ServeHTTP(0xc4203bbc60, 0xdf3160, 0xc4202e2540, 0xc420130c00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).routeHTTP(0xc4203e8d20, 0xdf3160, 0xc4202e2540, 0xc420130c00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:424 +0x289
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).(github.com/drone/drone/vendor/github.com/go-chi/chi.routeHTTP)-fm(0xdf3160, 0xc4202e2540, 0xc420130c00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:368 +0x48
net/http.HandlerFunc.ServeHTTP(0xc42045d6b0, 0xdf3160, 0xc4202e2540, 0xc420130c00)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).ServeHTTP(0xc4203e8d20, 0xdf3160, 0xc4202e2540, 0xc420130b00)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:81 +0x221
net/http.serverHandler.ServeHTTP(0xc420356000, 0xdf3160, 0xc4202e2540, 0xc420130b00)
        /usr/local/go/src/net/http/server.go:2694 +0xbc
net/http.(*conn).serve(0xc42009aa00, 0xdf3960, 0xc42006c380)
        /usr/local/go/src/net/http/server.go:1830 +0x651
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2795 +0x27b

Can you test without placing Caddy in front of Drone to rule out any proxy issues. If the request is cancelled or killed in transit it can cause a panic.

try without proxy, but also fail

run script

docker run --rm -ti \
  --name beta_drone \
  -p 80:80 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e DRONE_TLS_AUTOCERT=false \
  -e DRONE_GITLAB_SERVER=https://gitlab.com \
  -e DRONE_GITLAB_CLIENT_ID=xxxxxxx \
  -e DRONE_GITLAB_CLIENT_SECRET=xxxxxx \
  -e DRONE_SERVER_HOST=beta.drone.wsl.fun \
  -e DRONE_SERVER_PROTO=http \
  -e DRONE_PRIVATE_MODE=false \
  -e DRONE_LOGS_DEBUG=true \
  -e DRONE_RUNNER_CAPACITY=2 \
  drone/drone:0.9.0-alpha.1

drone server log

2018/09/11 15:38:34 http: panic serving 35.231.92.129:49000: runtime error: invalid memory address or nil pointer dereference
goroutine 119 [running]:
net/http.(*conn).serve.func1(0xc4200a1860)
        /usr/local/go/src/net/http/server.go:1726 +0xd0
panic(0xc49800, 0x138b0c0)
        /usr/local/go/src/runtime/panic.go:502 +0x229
github.com/drone/drone/internal/scm/hook/parser.(*parser).Parse(0xc4200ae858, 0xc420147800, 0xc4202c98e0, 0x1, 0x1, 0x0, 0x0)
        /go/src/github.com/drone/drone/internal/scm/hook/parser/parse.go:87 +0xba
github.com/drone/drone/internal/web.HandleHook.func1(0xdf3160, 0xc4201b8e00, 0xc420147800)
        /go/src/github.com/drone/drone/internal/web/hook.go:48 +0x102
net/http.HandlerFunc.ServeHTTP(0xc4202f4bc0, 0xdf3160, 0xc4201b8e00, 0xc420147800)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).routeHTTP(0xc42026b440, 0xdf3160, 0xc4201b8e00, 0xc420147800)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:424 +0x289
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).(github.com/drone/drone/vendor/github.com/go-chi/chi.routeHTTP)-fm(0xdf3160, 0xc4201b8e00, 0xc420147800)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:368 +0x48
net/http.HandlerFunc.ServeHTTP(0xc420394930, 0xdf3160, 0xc4201b8e00, 0xc420147800)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).ServeHTTP(0xc42026b440, 0xdf3160, 0xc4201b8e00, 0xc420147800)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:69 +0x2eb
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).Mount.func1(0xdf3160, 0xc4201b8e00, 0xc420147800)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:291 +0x107
net/http.HandlerFunc.ServeHTTP(0xc420470520, 0xdf3160, 0xc4201b8e00, 0xc420147800)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).routeHTTP(0xc42026b380, 0xdf3160, 0xc4201b8e00, 0xc420147800)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:424 +0x289
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).(github.com/drone/drone/vendor/github.com/go-chi/chi.routeHTTP)-fm(0xdf3160, 0xc4201b8e00, 0xc420147800)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:368 +0x48
net/http.HandlerFunc.ServeHTTP(0xc420394940, 0xdf3160, 0xc4201b8e00, 0xc420147800)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/rs/zerolog/hlog.RequestIDHandler.func1.1(0xdf3160, 0xc4201b8e00, 0xc420147800)
        /go/src/github.com/drone/drone/vendor/github.com/rs/zerolog/hlog/hlog.go:164 +0x149
net/http.HandlerFunc.ServeHTTP(0xc4202f4c40, 0xdf3160, 0xc4201b8e00, 0xc420147700)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/rs/zerolog/hlog.MethodHandler.func1.1(0xdf3160, 0xc4201b8e00, 0xc420147700)
        /go/src/github.com/drone/drone/vendor/github.com/rs/zerolog/hlog/hlog.go:58 +0xf5
net/http.HandlerFunc.ServeHTTP(0xc42046ef60, 0xdf3160, 0xc4201b8e00, 0xc420147700)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/rs/zerolog/hlog.URLHandler.func1.1(0xdf3160, 0xc4201b8e00, 0xc420147700)
        /go/src/github.com/drone/drone/vendor/github.com/rs/zerolog/hlog/hlog.go:44 +0xf5
net/http.HandlerFunc.ServeHTTP(0xc42046ef90, 0xdf3160, 0xc4201b8e00, 0xc420147700)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/rs/zerolog/hlog.RemoteAddrHandler.func1.1(0xdf3160, 0xc4201b8e00, 0xc420147700)
        /go/src/github.com/drone/drone/vendor/github.com/rs/zerolog/hlog/hlog.go:88 +0xc6
net/http.HandlerFunc.ServeHTTP(0xc42046efc0, 0xdf3160, 0xc4201b8e00, 0xc420147700)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/rs/zerolog/hlog.NewHandler.func1.1(0xdf3160, 0xc4201b8e00, 0xc420147600)
        /go/src/github.com/drone/drone/vendor/github.com/rs/zerolog/hlog/hlog.go:30 +0x39d
net/http.HandlerFunc.ServeHTTP(0xc4203690a0, 0xdf3160, 0xc4201b8e00, 0xc420147600)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi/middleware.NoCache.func1(0xdf3160, 0xc4201b8e00, 0xc420147600)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/middleware/nocache.go:54 +0x217
net/http.HandlerFunc.ServeHTTP(0xc420470540, 0xdf3160, 0xc4201b8e00, 0xc420147600)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).ServeHTTP(0xc42026b380, 0xdf3160, 0xc4201b8e00, 0xc420147600)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:69 +0x2eb
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).Mount.func1(0xdf3160, 0xc4201b8e00, 0xc420147600)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:291 +0x107
net/http.HandlerFunc.ServeHTTP(0xc4204707c0, 0xdf3160, 0xc4201b8e00, 0xc420147600)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).routeHTTP(0xc42026b2c0, 0xdf3160, 0xc4201b8e00, 0xc420147600)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:424 +0x289
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).(github.com/drone/drone/vendor/github.com/go-chi/chi.routeHTTP)-fm(0xdf3160, 0xc4201b8e00, 0xc420147600)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:368 +0x48
net/http.HandlerFunc.ServeHTTP(0xc4203949d0, 0xdf3160, 0xc4201b8e00, 0xc420147600)
        /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/drone/drone/vendor/github.com/go-chi/chi.(*Mux).ServeHTTP(0xc42026b2c0, 0xdf3160, 0xc4201b8e00, 0xc420147000)
        /go/src/github.com/drone/drone/vendor/github.com/go-chi/chi/mux.go:81 +0x221
net/http.serverHandler.ServeHTTP(0xc420390270, 0xdf3160, 0xc4201b8e00, 0xc420147000)
        /usr/local/go/src/net/http/server.go:2694 +0xbc
net/http.(*conn).serve(0xc4200a1860, 0xdf3960, 0xc4202f45c0)
        /usr/local/go/src/net/http/server.go:1830 +0x651
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2795 +0x27b

gitlab error

Connection reset by peer

I don’t set any drone agent follow the tutorial https://readme.drone.io/intro/gitlab/

@bradrydzewski this is a bug ?