caddyserver/xcaddy

xcaddy build fails behind proxy

Closed this issue ยท 6 comments

We are using a proxy at our office and are unable to run the xcaddy build in our docker environment. We have setup every environement variables linked to the proxy and are still unable.

All of the combinaition don't work

  • http_proxy={ourproxy}
  • https_proxy={ourproxy}
  • GOPROXY={ourproxy},direct

Here is the log

app_caddy_builder 4/4] RUN xcaddy build:
#0 0.314 2023/04/19 18:26:54 [INFO] Temporary folder: /tmp/buildenv_2023-04-19-1826.642888126
#0 0.314 2023/04/19 18:26:54 [INFO] Writing main module: /tmp/buildenv_2023-04-19-1826.642888126/main.go
#0 0.314 package main
#0 0.314
#0 0.314 import (
#0 0.314        caddycmd "[github.com/caddyserver/caddy/v2/cmd](http://github.com/caddyserver/caddy/v2/cmd)"
#0 0.314
#0 0.314        // plug in Caddy modules here
#0 0.314        _ "[github.com/caddyserver/caddy/v2/modules/standard](http://github.com/caddyserver/caddy/v2/modules/standard)"
#0 0.314 )
#0 0.314
#0 0.314 func main() {
#0 0.314        caddycmd.Main()
#0 0.314 }
#0 0.314 2023/04/19 18:26:54 [INFO] Initializing Go module
#0 0.314 2023/04/19 18:26:54 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
#0 0.317 go: creating new go.mod: module caddy
#0 0.317 go: to add module requirements and sums:
#0 0.317        go mod tidy
#0 0.318 2023/04/19 18:26:54 [INFO] Pinning versions
#0 0.318 2023/04/19 18:26:54 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v [github.com/caddyserver/caddy/v2@v2](http://github.com/caddyserver/caddy/v2@v2)
.6.4
#0 30.32 go: [github.com/caddyserver/caddy/v2@v2.6.4](http://github.com/caddyserver/caddy/v2@v2.6.4): Get "https://proxy.golang.org/github.com/caddyserver/caddy/v2/@v/v2
.[6.4.info](http://6.4.info/)": proxyconnect tcp: dial tcp {ourproxyIP}: i/o timeout
#0 30.33 2023/04/19 18:27:24 [FATAL] exit status 1
mholt commented

What is your actual xcaddy command? The log looks... unusual: http://6.4.info/

Here is the part in our DockerFile that don't work behind a proxy

FROM caddy:2-builder-alpine AS app_caddy_builder

ARG PROXY="http://{ourproxy}:{port}"
# force env var to be sure
ENV HTTP_PROXY ${PROXY}
ENV HTTPS_PROXY ${PROXY}
RUN export https_proxy=${PROXY}
RUN export http_proxy=${PROXY}

RUN xcaddy build \
	--with github.com/dunglas/mercure \
	--with github.com/dunglas/mercure/caddy \
	--with github.com/dunglas/vulcain \
	--with github.com/dunglas/vulcain/caddy

Is the address you're setting GOPROXY var the address of a server that's compliant of the Go proxy protocol? If not, don't set it. Just set it to direct.

https://go.dev/ref/mod#goproxy-protocol

Is the address you're setting GOPROXY var the address of a server that's compliant of the Go proxy protocol? If not, don't set it. Just set it to direct.

https://go.dev/ref/mod#goproxy-protocol

Thanks, I put it there to show I tried it, bit even without it I have the problem. We can put this on hold I will make sure it is not an issue with our network first.

I've just validated that xcaddy works with those env vars set using 3proxy as the proxy server. Here are the logs upon running xcaddy build:

/bin/3proxy: Starting 3proxy
{"time_unix":1681944954, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"0.0.0.0", "port":3128}, "server":{"ip":"0.0.0.0", "port":0}, "bytes":{"sent":0, "received":0}, "request":{"hostname":"[0.0.0.0]"}, "message":"Accepting connections [7/2436343552]"}
{"time_unix":1681944954, "proxy":{"type:":"SOCKS", "port":1080}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"0.0.0.0", "port":1080}, "server":{"ip":"0.0.0.0", "port":0}, "bytes":{"sent":0, "received":0}, "request":{"hostname":"[0.0.0.0]"}, "message":"Accepting connections [7/2436273920]"}
{"time_unix":1681945231, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":41926}, "server":{"ip":"142.250.179.164", "port":443}, "bytes":{"sent":883, "received":20406}, "request":{"hostname":"www.google.com"}, "message":"CONNECT www.google.com:443 HTTP/1.1"}
{"time_unix":1681945238, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":41940}, "server":{"ip":"13.227.219.56", "port":443}, "bytes":{"sent":851, "received":10433}, "request":{"hostname":"dl.cloudsmith.io"}, "message":"CONNECT dl.cloudsmith.io:443 HTTP/1.1"}
{"time_unix":1681945283, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":39926}, "server":{"ip":"13.227.219.56", "port":443}, "bytes":{"sent":856, "received":6955}, "request":{"hostname":"dl.cloudsmith.io"}, "message":"CONNECT dl.cloudsmith.io:443 HTTP/1.1"}
{"time_unix":1681945324, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":41920}, "server":{"ip":"142.251.36.49", "port":443}, "bytes":{"sent":370, "received":10396}, "request":{"hostname":"proxy.golang.org"}, "message":"CONNECT proxy.golang.org:443 HTTP/1.1"}
{"time_unix":1681945324, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":41930}, "server":{"ip":"142.251.39.113", "port":443}, "bytes":{"sent":370, "received":10397}, "request":{"hostname":"proxy.golang.org"}, "message":"CONNECT proxy.golang.org:443 HTTP/1.1"}
{"time_unix":1681945324, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":41942}, "server":{"ip":"216.58.208.113", "port":443}, "bytes":{"sent":370, "received":10397}, "request":{"hostname":"proxy.golang.org"}, "message":"CONNECT proxy.golang.org:443 HTTP/1.1"}
{"time_unix":1681945324, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":41952}, "server":{"ip":"142.250.179.209", "port":443}, "bytes":{"sent":368, "received":10397}, "request":{"hostname":"sum.golang.org"}, "message":"CONNECT sum.golang.org:443 HTTP/1.1"}
{"time_unix":1681945340, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":41934}, "server":{"ip":"142.251.36.49", "port":443}, "bytes":{"sent":103120, "received":28121656}, "request":{"hostname":"proxy.golang.org"}, "message":"CONNECT proxy.golang.org:443 HTTP/1.1"}
{"time_unix":1681945340, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":41948}, "server":{"ip":"216.58.214.17", "port":443}, "bytes":{"sent":117224, "received":4716945}, "request":{"hostname":"sum.golang.org"}, "message":"CONNECT sum.golang.org:443 HTTP/1.1"}
{"time_unix":1681945340, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":42654}, "server":{"ip":"216.58.208.113", "port":443}, "bytes":{"sent":370, "received":10398}, "request":{"hostname":"proxy.golang.org"}, "message":"CONNECT proxy.golang.org:443 HTTP/1.1"}
{"time_unix":1681945340, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":42660}, "server":{"ip":"142.250.179.209", "port":443}, "bytes":{"sent":368, "received":10397}, "request":{"hostname":"sum.golang.org"}, "message":"CONNECT sum.golang.org:443 HTTP/1.1"}
{"time_unix":1681945363, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"}, "auth":{"user":"-"}, "client":{"ip":"172.18.0.1", "port":42644}, "server":{"ip":"216.58.208.113", "port":443}, "bytes":{"sent":119710, "received":22811265}, "request":{"hostname":"proxy.golang.org"}, "message":"CONNECT proxy.golang.org:443 HTTP/1.1"}
{"time_unix":1681945363, "proxy":{"type:":"PROXY", "port":3128}, "error":{"code":"00000"},

I only set HTTP_PROXY and HTTPS_PROXY. In my case, the value for both was the same, which is http://localhost:3128.

Thank you for checking, I will close this issue and make some validation on our side, since it was working for on of our devs.