Server gives error when launching client

Hello. I’m trying to run a boringproxy server behind an Haproxy instance and trying to create a tunnel to my local computer. I can launch the server without any problems and access the interface, but when I try to create a client in my computer the server gives an error, as it can be sene in the following piece of code.

2022/11/16 15:50:13 Ready
2022-11-16T15:50:20Z POST <domain-name> /api/clients/
2022/11/16 15:50:20 http: panic serving assignment to entry in nil map
goroutine 26 [running]:
	/home/anders/go/src/net/http/server.go:1801 +0xb9
panic({0x8a27e0, 0x9c4f60})
	/home/anders/go/src/runtime/panic.go:1047 +0x266*Api).SetClient(0xc000144f30, {{0xc000022d00, 0x203000}, {0x0, 0x20}}, 0xc0000fd288, {0xc000022460, 0x6}, {0xc0003db49f, 0x7})
	/home/anders/code/boringproxy/api.go:544 +0xb4*Api).handleClients(0xc000144f30, {0x9d2578, 0xc0001368c0}, 0xc0000f6500)
	/home/anders/code/boringproxy/api.go:253 +0x3e8
net/http.HandlerFunc.ServeHTTP(0xc0000bf040, {0x9d2578, 0xc0001368c0}, 0x5)
	/home/anders/go/src/net/http/server.go:2046 +0x2f
net/http.StripPrefix.func1({0x9d2578, 0xc0001368c0}, 0xc0000f6400)
	/home/anders/go/src/net/http/server.go:2089 +0x330
net/http.HandlerFunc.ServeHTTP(0x7f4b1b29e318, {0x9d2578, 0xc0001368c0}, 0x7f4b1b294108)
	/home/anders/go/src/net/http/server.go:2046 +0x2f
net/http.(*ServeMux).ServeHTTP(0x40cfe7, {0x9d2578, 0xc0001368c0}, 0xc0000f6400)
	/home/anders/go/src/net/http/server.go:2424 +0x149*Api).ServeHTTP(0x30, {0x9d2578, 0xc0001368c0}, 0x10000c00010dd30)
	/home/anders/code/boringproxy/api.go:37 +0x27
net/http.StripPrefix.func1({0x9d2578, 0xc0001368c0}, 0xc0000f6300)
	/home/anders/go/src/net/http/server.go:2089 +0x330
net/http.HandlerFunc.ServeHTTP(0x91d9b9, {0x9d2578, 0xc0001368c0}, 0xc000144f30)
	/home/anders/go/src/net/http/server.go:2046 +0x2f{0x9d2578, 0xc0001368c0}, 0xc0000f6300)
	/home/anders/code/boringproxy/boringproxy.go:278 +0x3df
net/http.HandlerFunc.ServeHTTP(0x0, {0x9d2578, 0xc0001368c0}, 0x0)
	/home/anders/go/src/net/http/server.go:2046 +0x2f
net/http.(*ServeMux).ServeHTTP(0xc0003db493, {0x9d2578, 0xc0001368c0}, 0xc0000f6300)
	/home/anders/go/src/net/http/server.go:2424 +0x149
net/http.serverHandler.ServeHTTP({0xc000145470}, {0x9d2578, 0xc0001368c0}, 0xc0000f6300)
	/home/anders/go/src/net/http/server.go:2878 +0x43b
net/http.(*conn).serve(0xc00013ef00, {0x9d48e0, 0xc000145380})
	/home/anders/go/src/net/http/server.go:1929 +0xb08
created by net/http.(*Server).Serve
	/home/anders/go/src/net/http/server.go:3033 +0x4e8

And the client returns this:

Failed to create client. Ensure the server is running. URL: https://<domain-name>/api/clients/?client-name=localpc&user=admin% 

The Haproxy logs the following event:

Nov 16 15:50:50 ip-172-31-34-167 haproxy[24004]: <event-source-ip> [16/Nov/2022:15:50:50.058] main/2: SSL handshake failure

Why could it be?

The commands I execute are the followings:

  • server:
./boringproxy-linux-x86_64 server -allow-http -http-port 8000  -admin-domain <domain-name>

I have tried with flag “-behind-proxy” but the output is the same

  • client:
 ./boringproxy-linux-x86_64 client -server <domain-name> -user admin -token <token> -client-name localpc

The Haproxy conf is the following one:

frontend main
    bind *:80
    bind *:443 ssl  crt /etc/haproxy/server.pem verify none
    mode http

    log /dev/log local2 debug
   # http-request set-header X-Forwarded-Proto https if { ssl_fc }
  #  http-request set-header X-Forwarded-Port %[dst_port]
    #option forwardfor
    default_backend             bproxy

backend bproxy
   mode http
   server server1
 #  http-request set-header host


Edit: When I launch the client the request doesn’t arrive to the BP server, it just gives the SSL handshake failure in Haproxy. The error in the server happens when I copy the link displayed in the client response and try to access it.

Hi @ivan-arrizabalaga, can you inspect boringproxy_db.json and make sure there are no nulls in there?

Hi @anders, thanks for you reply! This is my boringproxy_db.json:

  "admin_domain": "<domain-name>",
  "tokens": {
    "<token>": {
      "owner": "admin"
  "tunnels": {},
  "users": {
    "admin": {
      "is_admin": true,
      "clients": {}

Sorry for the delay. DB looks ok. What version are you running? I can use that to try and track down the panic from the error you posted.