Hello,
I am trying to make drone working with HTTPS on host network.
I need to run it on host network (docker run ... --network=host
) because I have my gitea instance installed locally and not on docker, so I need drone’s container to be able to reach the host’s ports.
Ports 80 and 443 are already used on the host (by a reverse proxy), so I need drone to listen to some other ports.
If I am using plain HTTP, this works out fine.
I pass the environment variable DRONE_SERVER_PORT=:8082
and drone listens on port 8082 instead of port 80.
It connects to the local gitea instance and it accepts connections to the runners.
If, however, I use HTTPS and provide a certificate and a private key, drone still (tries to) bind port 443, regardless of the content of environment variable DRONE_SERVER_PORT
.
Since port 443 is already in use, it fails.
I tried to look at the code, but I am not familiar with golang, and I could not figure out where the problem might be.
I tried to trivially replace the only occurrence of the string 443
with 8082
, recompile and create a custom docker image, but it did not work.
I realize the solution would be trivial if I could run drone contained on docker’s network and remap port 443 to some other port, but unfortunately I cannot do that.
This is the command I run to create the container.
If I remove the environment variables DRONE_TLS_CERT
and DRONE_TLS_KEY
and set DRONE_SERVER_PROTO=http
, it correctly binds to port 8082 (obviously without using HTTPS).
docker run \
--volume=/var/lib/drone:/data \
--volume=/etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt:ro \
--volume=/path/to/drone.cert.pem:/etc/certs/drone.cert.pem:ro \
--volume=/path/to/drone.key.pem.nopasswd:/etc/certs/drone.key.pem.nopasswd:ro \
--env=DRONE_TLS_CERT=/etc/certs/drone.cert.pem \
--env=DRONE_TLS_KEY=/etc/certs/drone.key.pem.nopasswd \
--env=DRONE_GITEA_SERVER=${DRONE_GITEA_SERVER} \
--env=DRONE_GITEA_CLIENT_ID=${DRONE_GITEA_CLIENT_ID} \
--env=DRONE_GITEA_CLIENT_SECRET=${DRONE_GITEA_CLIENT_SECRET} \
--env=DRONE_GITEA_SKIP_VERIFY=false \
--env=DRONE_RPC_SECRET=${DRONE_RPC_SECRET} \
--env=DRONE_SERVER_HOST=drone.localdomain:8082 \
--env=DRONE_SERVER_PORT=:8082 \
--env=DRONE_SERVER_PROTO=https \
--restart=always \
--detach=true \
--name=drone \
--network=host \
drone/drone:1
Perhaps DRONE_SERVER_PORT
only controls the HTTP port, and not the HTTPS port?
Is there then another environment variable for HTTPS?
Any other ideas?