unmojang / drasl

Yggdrasil-compatible API server for Minecraft
GNU General Public License v3.0
69 stars 11 forks source link

`connection refused` spit by caddy with the example configuration #60

Closed cyrneko closed 2 months ago

cyrneko commented 2 months ago

Hey there!

I've recently found this project and wanted to try self-hosting it. I've followed the instructions in installation.md and configuration.md to get the sample docker-caddy configuration. I'm running this all over Tailscale. My files currently look like this:

docker-compose.yml

version: "3"

services:
  caddy:
    image: docker.io/caddy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./caddy/data:/data
      - ./caddy/config:/config
  drasl:
    image: docker.io/unmojang/drasl
    ports:
      - "25585:25585"
    volumes:
      - ./config:/etc/drasl
      - ./data:/var/lib/drasl

Caddyfile

# Should be the same as `Domain` in Drasl's config.toml
http://epic-server.faun-scala.ts.net

reverse_proxy :25585

(I have added http:// in front to disable automatic HTTPs as it does not play nice with my Tailscale config at the moment)

config.toml

# Drasl default config file

# Example: drasl.example.com
Domain = "epic-server.faun-scala.ts.net"

# Example: https://drasl.example.com
BaseURL = "http://epic-server.faun-scala.ts.net"

ListenAddress = "127.0.0.1:25585"

# List of usernames who automatically become admins of the Drasl instance
DefaultAdmins = ["cyrus"]

[RegistrationNewPlayer]
Allow = true
AllowChoosingUUID = true
RequireInvite = true

However, when I run docker compose up and look at the log, Caddy returns an empty page because of the following error:

{"level":"error","ts":1713493140.6753414,"logger":"http.log.error","msg":"dial tcp 127.0.0.1:25585: connect: connection refused","request":{"remote_ip":"172.22.0.1","remote_port":"45926","client_ip":"172.22.0.1","proto":"HTTP/1.1","method":"GET","host":"epic-server.faun-scala.ts.net","uri":"/","headers":{"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"],"Accept-Encoding":["gzip, deflate"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0"],"Sec-Gpc":["1"],"Upgrade-Insecure-Requests":["1"],"Accept-Language":["en-US,en;q=0.5"],"Dnt":["1"]}},"duration":0.000841842,"status":502,"err_id":"q1a5zcsr1","err_trace":"reverseproxy.statusError (reverseproxy.go:1267)"}

I cannot for the life of me get Drasl to not refuse the connection from Caddy, and would like some help figuring out what the hell is going on as someone which only recently dabbled in hosting things like Caddy

evan-goode commented 2 months ago

Sorry, I think the example config was wrong here, maybe something was off about my Docker setup when I tested it.

Could you try the changes in https://github.com/unmojang/drasl/pull/61 and see if that works? The main thing is changing the Caddyfile to try to communicate with the Drasl container at drasl:25585 and not just :25585, which I believe fails because there is nothing listening on tcp/25585 on the Caddy container's internal network.

cyrneko commented 2 months ago

applied the change, same result it seems. I made sure to run docker compose up --force-recreate just to be sure

relevant error:

{"level":"error","ts":1713499643.2489705,"logger":"http.log.error","msg":"dial tcp 172.20.0.2:25585: connect: connection refused","request":{"remote_ip":"100.90.39.45","remote_port":"59070","client_ip":"100.90.39.45","proto":"HTTP/1.1","method":"GET","host":"epic-server.faun-scala.ts.net","uri":"/favicon.ico","headers":{"Accept-Encoding":["gzip, deflate"],"Dnt":["1"],"Sec-Gpc":["1"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0"],"Accept":["image/avif,image/webp,*/*"],"Accept-Language":["en-US,en;q=0.5"],"Referer":["http://epic-server.faun-scala.ts.net/"]}},"duration":0.001390832,"status":502,"err_id":"8pc1mwrgp","err_trace":"reverseproxy.statusError (reverseproxy.go:1267)"}

(I don't think anything actually changed here)

evan-goode commented 2 months ago

Strange, it works for me now. I'm also using Tailscale. Docker 24.0.5 on NixOS. Here is my full config:

working-drasl-config.tar.gz

Maybe try ping the Drasl container from the Caddy container?

docker exec -it YOURCADDYCONTAINER ping drasl
cyrneko commented 2 months ago

works fine :woozy_face:

server@epic-server:~ ❯ docker exec -it 8c5bccad76a5 ping drasl
PING drasl (172.20.0.2): 56 data bytes
64 bytes from 172.20.0.2: seq=0 ttl=64 time=0.178 ms
64 bytes from 172.20.0.2: seq=1 ttl=64 time=0.092 ms
64 bytes from 172.20.0.2: seq=2 ttl=64 time=0.091 ms
^C
--- drasl ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.091/0.120/0.178 ms
evan-goode commented 2 months ago

Ok, in the Docker logs (or docker compose output if you run it without -d), does Drasl indicate that it's listening on ::25585?

The ListenAddress in Drasl's config should be kept as the default value, NOT 127.0.0.1:25585.

cyrneko commented 2 months ago

working-drasl-config.tar.gz

update: this works?!

cyrneko commented 2 months ago

The ListenAddress in Drasl's config should be kept as the default value, NOT 127.0.0.1:25585.

oh, well, I must've misread the docs then. Thanks for your support! :)

evan-goode commented 2 months ago

Nice, no problem!

Yes, the docs are unclear on that, I'll add a change to the linked PR to clarify things. Leaving this issue open until #61 is merged.