joesturge / lazymc-docker-proxy

Put your Minecraft containers to rest when idle.
GNU General Public License v3.0
27 stars 4 forks source link

trying to create dual setup using a forge and neoforge server #69

Closed Molier closed 3 months ago

Molier commented 3 months ago

I want to run bettermc4 and ATM10 in tandem on port 25565 and 25566. so that i can then proxy them to some subdomain using fe. Caddy. so 2 different ips on the local machine.

config

Im trying to use the example config provided from the testing files, since that seems to be a good minimal setup. But there is some conflicting info on the main readme and in those tests and can not seem to get any working config.

code

services:
  lazymc:
    container_name: lazymc
    image: ghcr.io/joesturge/lazymc-docker-proxy:latest
    # environment:
    #   SERVER_ADDRESS: mc:25565
    #   SERVER_ADDRESS: mc:25566
    restart: unless-stopped
    volumes:
      - databettermc:/server/bettermc:ro
      - dataatm:/server/atm:ro
      - '/run/user/1000/docker.sock:/var/run/docker.sock'
    ports:
      # lazymc-docker-proxy acts as a proxy, so only the lazymc container needs to expose the ports
      - "25565:25565"
      - "25566:25566"

  bettermc4:
    image: itzg/minecraft-server
    container_name: bmc4
    labels:
      - lazymc.enabled=true
      - lazymc.group=bettermc4
      - lazymc.server.address=mc:25565
      - lazymc.port=25565
      - lazymc.server.forge=true
      # important to set the version and protocol to the correct values 
      # https://wiki.vg/Protocol_version_numbers#Versions_after_the_Netty_rewrite
      - lazymc.public.version=1.20.1
      - lazymc.public.protocol=763
      # TODO extend time out
      - lazymc.time.sleep_after=30
      - lazymc.time.minimum_online_time=100
    tty: true
    stdin_open: true
    restart: no
    environment:
      EULA: true
      MOD_PLATFORM: AUTO_CURSEFORGE
      CF_API_KEY: ${CF_API_KEY}
      CF_SLUG: better-mc-forge-bmc4
      CF_FORCE_SYNCHRONIZE: "true"
      CF_EXCLUDE_MODS: | # remove problematic client side mods
          xaeros-minimap
          xaeroplus
          yungs-menu-tweaks
      MEMORY: 4G
      TYPE: FORGE
    volumes:
      - databettermc:/data

  atm10:
    container_name: atm10
    image: itzg/minecraft-server
    environment:
      MEMORY: 8G
      EULA: true
      TYPE: NEOFORGE
      VERSION: latest
      NEOFORGE_VERSION: beta
    labels:
      - lazymc.enabled=true
      - lazymc.group=atm10
      # Point to the service name of the Minecraft server
      - lazymc.server.address=atm10:25566
      - lazymc.port=25566
      - lazymc.server.forge=true
      - lazymc.public.version=1.21
      - lazymc.public.protocol=767
    tty: true
    stdin_open: true
    restart: no
    volumes:
      - dataatm:/data
volumes:
  databettermc:
  dataatm:

any advice is appreciated, no error logs included since the docker config is most likely the issue. Is this use case not possible without using the mc-router? here are the examples for the itz servers for reference as well.

Molier commented 3 months ago

after testing the repo, including the bats tests and looking deeper into it. I don't understand how this is supposed to be functional and can not get any example from the repo working. not from the readme , or from the test files. Ask away if you want log or test outputs to try and fix it, will happily test and fix it as well. I can't get it to work on an ubuntu docker setup. Im going back to dual lazymc setup for now.

joesturge commented 3 months ago

Hi Thanks for submitting this issue - let me look into this, you wouldnt happen to have any logs from the compose environment would you?

Also make sure you are definatly using the latest version of the docker image

docker pull ghcr.io/joesturge/lazymc-docker-proxy:latest

In the meantime, could you try chaging this line in atm10:

      - lazymc.server.address=atm10:25566

to this

      - lazymc.server.address=atm10:25565

That label tells lazymc which address to test the server up status, which needs to be the original address of the server before proxying.

Also you will need to use a network with static IPs as suggested in the readme. This is because docker does not retain the original IP of the container, and lazymc does not expect the IP to change

joesturge commented 3 months ago

Could you try with this updated docker compose?

networks:
  minecraft-network:
    driver: bridge    
    ipam:
      config:
        - subnet: 172.22.0.0/16

services:
  lazymc:
    container_name: lazymc
    networks:
      minecraft-network:
        ipv4_address: 172.22.0.2
    image: ghcr.io/joesturge/lazymc-docker-proxy:latest
    # environment:
    #   SERVER_ADDRESS: mc:25565
    #   SERVER_ADDRESS: mc:25566
    restart: unless-stopped
    volumes:
      - databettermc:/server/bettermc:ro
      - dataatm:/server/atm:ro
      - '/run/user/1000/docker.sock:/var/run/docker.sock'
    ports:
      # lazymc-docker-proxy acts as a proxy, so only the lazymc container needs to expose the ports
      - "25565:25565"
      - "25566:25566"

  bettermc4:
    image: itzg/minecraft-server
    container_name: bmc4
    networks:
      minecraft-network:
        ipv4_address: 172.22.0.3
    labels:
      - lazymc.enabled=true
      - lazymc.group=bettermc4
      - lazymc.server.address=mc:25565
      - lazymc.port=25565
      - lazymc.server.forge=true
      # important to set the version and protocol to the correct values 
      # https://wiki.vg/Protocol_version_numbers#Versions_after_the_Netty_rewrite
      - lazymc.public.version=1.20.1
      - lazymc.public.protocol=763
      # TODO extend time out
      - lazymc.time.sleep_after=30
      - lazymc.time.minimum_online_time=100
    tty: true
    stdin_open: true
    restart: no
    environment:
      EULA: true
      MOD_PLATFORM: AUTO_CURSEFORGE
      CF_API_KEY: ${CF_API_KEY}
      CF_SLUG: better-mc-forge-bmc4
      CF_FORCE_SYNCHRONIZE: "true"
      CF_EXCLUDE_MODS: | # remove problematic client side mods
          xaeros-minimap
          xaeroplus
          yungs-menu-tweaks
      MEMORY: 4G
      TYPE: FORGE
    volumes:
      - databettermc:/data

  atm10:
    container_name: atm10
    networks:
      minecraft-network:
        ipv4_address: 172.22.0.4
    image: itzg/minecraft-server
    environment:
      MEMORY: 8G
      EULA: true
      TYPE: NEOFORGE
      VERSION: latest
      NEOFORGE_VERSION: beta
    labels:
      - lazymc.enabled=true
      - lazymc.group=atm10
      # Point to the service name of the Minecraft server
      - lazymc.server.address=atm10:25565
      - lazymc.port=25566
      - lazymc.server.forge=true
      - lazymc.public.version=1.21
      - lazymc.public.protocol=767
    tty: true
    stdin_open: true
    restart: no
    volumes:
      - dataatm:/data
volumes:
  databettermc:
  dataatm:
joesturge commented 3 months ago

I would not reccomend using the tests as workable examples. I should add more examples to the docs, ive added a new issue here: https://github.com/joesturge/lazymc-docker-proxy/issues/72

Molier commented 3 months ago

I figured out as well that atm10 will not work since lazymc doesnt support its protocol version, 1.21 mc with protocol 767 is not supported yet it seems? although now it seems to work a bit better, did you add support for it?

Your example compose boots, after some small changes, and some troubleshooting, I think the biggest problem was

heres the compose:

networks:
  minecraft-network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.22.0.0/16

services:
  lazymc:
    container_name: lazymc
    networks:
      minecraft-network:
        ipv4_address: 172.22.0.2
    image: ghcr.io/joesturge/lazymc-docker-proxy:latest

    restart: unless-stopped
    volumes:
      - databettermc:/server/bettermc:ro
      - dataatm:/server/atm:ro
      - "/run/user/1000/docker.sock:/var/run/docker.sock"
    ports:
      # lazymc-docker-proxy acts as a proxy, so only the lazymc container needs to expose the ports
      - "25565:25565"
      - "25566:25566"

  bmc4:
    image: itzg/minecraft-server
    container_name: bmc4
    networks:
      minecraft-network:
        ipv4_address: 172.22.0.3
    labels:
      - lazymc.enabled=true
      - lazymc.group=bmc4
      - lazymc.server.address=bmc4:25565
      - lazymc.port=25565
      - lazymc.server.forge=true
      # important to set the version and protocol to the correct values
      # https://wiki.vg/Protocol_version_numbers#Versions_after_the_Netty_rewrite
      - lazymc.public.version=1.20.1
      - lazymc.public.protocol=763
      # TODO extend time out
      - lazymc.time.sleep_after=30
      - lazymc.time.minimum_online_time=100
    tty: true
    stdin_open: true
    restart: no
    environment:
      EULA: true
      MOD_PLATFORM: AUTO_CURSEFORGE
      CF_API_KEY: ${CF_API_KEY}
      CF_SLUG: better-mc-forge-bmc4
      CF_FORCE_SYNCHRONIZE: "true"
      CF_EXCLUDE_MODS: | # remove problematic client side mods
        xaeros-minimap
        xaeroplus
        yungs-menu-tweaks
        561885
        just-zoom
      MEMORY: 4G
      TYPE: FORGE
    volumes:
      - databettermc:/data

  atm10:
    container_name: atm10
    networks:
      minecraft-network:
        ipv4_address: 172.22.0.4
    image: itzg/minecraft-server
    environment:
      MEMORY: 8G
      EULA: true
      MOD_PLATFORM: AUTO_CURSEFORGE
      CF_API_KEY: ${CF_API_KEY}
      CF_SLUG: all-the-mods-10
      CF_FORCE_SYNCHRONIZE: "true"
      CF_EXCLUDE_MODS: | # remove problematic client side mods
        lighty
        986380
      TYPE: NEOFORGE
      VERSION: 1.21
      NEOFORGE_VERSION: 21.0.167
    labels:
      - lazymc.enabled=true
      - lazymc.group=atm10
      # Point to the service name of the Minecraft server
      - lazymc.server.address=atm10:25565
      - lazymc.port=25566
      - lazymc.server.forge=true
      - lazymc.public.version=1.21
      - lazymc.public.protocol=767
    tty: true
    stdin_open: true
    restart: no
    volumes:
      - dataatm:/data
volumes:
  databettermc:
  dataatm:

and here some logs: docker compose logs lazymc -f

lazymc  |  INFO  lazymc-docker-proxy::entrypoint > Starting lazymc process for group: bmc4...
lazymc  |  INFO  lazymc-docker-proxy::entrypoint > Starting lazymc process for group: atm10...
lazymc  |  INFO  atm10::lazymc                   > Proxying public 0.0.0.0:25566 to server 172.22.0.4:25565
lazymc  |  INFO  atm10::lazymc                   > Starting server...
lazymc  |  WARN  atm10::lazymc                   > Failed to read property from server.properties file, it does not exist
lazymc  |  INFO  bmc4::lazymc                    > Proxying public 0.0.0.0:25565 to server 172.22.0.3:25565
lazymc  |  INFO  atm10::lazymc::monitor          > Server is now online
lazymc  |  INFO  bmc4::lazymc                    > Starting server...
lazymc  |  INFO  bmc4::lazymc-docker-proxy::command > Starting server...
lazymc  |  WARN  bmc4::lazymc                       > Failed to read property from server.properties file, it does not exist
lazymc  |  INFO  atm10::lazymc-docker-proxy::command > Starting server...
lazymc  |  INFO  bmc4::lazymc::monitor               > Server is now online
lazymc  |  INFO  lazymc-docker-proxy::entrypoint > Starting lazymc process for group: bmc4...
lazymc  |  INFO  lazymc-docker-proxy::entrypoint > Starting lazymc process for group: atm10...
lazymc  |  INFO  bmc4::lazymc                    > Proxying public 0.0.0.0:25565 to server 172.22.0.3:25565
lazymc  |  INFO  atm10::lazymc                   > Proxying public 0.0.0.0:25566 to server 172.22.0.4:25565
lazymc  |  INFO  bmc4::lazymc                    > Starting server...
lazymc  |  INFO  atm10::lazymc                   > Starting server...
lazymc  |  INFO  atm10::lazymc-docker-proxy::command > Starting server...
lazymc  |  INFO  bmc4::lazymc-docker-proxy::command  > Starting server...
lazymc  |  INFO  atm10::lazymc::monitor              > Server is now online
lazymc  |  INFO  bmc4::lazymc::monitor               > Server is now online
lazymc  |  WARN  bmc4::lazymc                        > Failed to read property from server.properties file, it does not exist
lazymc  |  WARN  atm10::lazymc                       > Failed to read property from server.properties file, it does not exist
lazymc  |  INFO  bmc4::lazymc::montior               > Server has been idle, sleeping...
lazymc  |  INFO  bmc4::lazymc-docker-proxy::command  > Received SIGTERM, stopping server...
lazymc  |  INFO  bmc4::lazymc-docker-proxy::command::docker > Stopping container: /bmc4
lazymc  |  INFO  bmc4::lazymc::monitor                      > Server is now sleeping
lazymc  |  INFO  atm10::lazymc::monitor                     > Server has been idle, sleeping...
lazymc  |  INFO  atm10::lazymc-docker-proxy::command        > Received SIGTERM, stopping server...
lazymc  |  INFO  atm10::lazymc-docker-proxy::command::docker > Stopping container: /atm10
lazymc  |  INFO  atm10::lazymc::monitor                      > Server is now sleeping

and some screenshots Screenshot 2024-08-13 224653 image

joesturge commented 3 months ago

Hi glad to hear that progress was made, those logs look good to me 👍

Yeah i added support for older protocol versions with this closed PR: https://github.com/joesturge/lazymc-docker-proxy/pull/43

I can address the documentation issues you raised, thanks!

Virtual hostnames will not work. Lazymc uses a TCP Socket which requires an IP addess, not a hostname. I have explained more in this issue: https://github.com/joesturge/lazymc-docker-proxy/issues/63

But basically when lazymc first starts it does a DNS lookup of the address you give it and internally stores an IP address. You could use the static IP as the the lazymc.server.address such as:

lazymc.server.address=172.22.0.3:25565

to remove all doubt

joesturge commented 3 months ago

I think I can see your issue with 1.21

Try just removing these lines from the atm10:

      - lazymc.public.version=1.21
      - lazymc.public.protocol=767
joesturge commented 3 months ago

I got it to work with 1.21 vanilla using this config

vanilla:
    image: itzg/minecraft-server
    networks:
      minecraft-network:
        ipv4_address: 172.22.0.5
    labels:
      - lazymc.enabled=true
      - lazymc.group=vanilla
      - lazymc.port=25565
      - lazymc.server.directory=/server/vanilla
      - lazymc.server.address=vanilla:25565
    tty: true
    stdin_open: true
    restart: no
    environment:
      EULA: "TRUE"
    volumes:
      - /home/joe/minecraft/vanilla/data:/data
joesturge commented 3 months ago

@Molier are you happy for me to close this issue? or was there anything else?

Molier commented 3 months ago

No thank you that seems to have fixed it, its working fine except the one server, atm10, doesnt correctly show the server status and message etc in the server browser. Maybe an issue with the protocol communication or something? Don't know but its functional so I dont mind 👍 . here is my current docker compose for reference/documentation purposes. #72

networks:
  minecraft-network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.22.0.0/16

services:
  lazymc:
    container_name: lazymc
    networks:
      minecraft-network:
        ipv4_address: 172.22.0.2
    image: ghcr.io/joesturge/lazymc-docker-proxy:latest

    restart: unless-stopped
    volumes:
      - databettermc:/server/bettermc:ro
      - dataatm:/server/atm:ro
      - vanilla:/server/vanilla:ro
      - "/run/user/1000/docker.sock:/var/run/docker.sock"
    ports:
      # lazymc-docker-proxy acts as a proxy, so only the lazymc container needs to expose the ports
      - "25565:25565"
      - "25566:25566"
      - "25567:25567"

  bmc4:
    image: itzg/minecraft-server
    container_name: bmc4
    networks:
      minecraft-network:
        ipv4_address: 172.22.0.3
    labels:
      - lazymc.enabled=true
      - lazymc.group=bmc4
      - lazymc.server.address=bmc4:25565
      - lazymc.port=25565
      - lazymc.server.forge=true
      # important to set the version and protocol to the correct values
      # https://wiki.vg/Protocol_version_numbers#Versions_after_the_Netty_rewrite
      - lazymc.public.version=1.20.1
      - lazymc.public.protocol=763
      # TODO extend time out
      - lazymc.time.sleep_after=30
      - lazymc.time.minimum_online_time=100
    tty: true
    stdin_open: true
    restart: no
    environment:
      DIFFICULTY: hard
      EULA: true
      MOD_PLATFORM: AUTO_CURSEFORGE
      CF_API_KEY: ${CF_API_KEY}
      CF_SLUG: better-mc-forge-bmc4
      CF_FORCE_SYNCHRONIZE: "true"
      CF_EXCLUDE_MODS: | # remove problematic client side mods
        xaeros-minimap
        xaeroplus
        yungs-menu-tweaks
        561885
        just-zoom
      MEMORY: 4G
      TYPE: FORGE
    volumes:
      - databettermc:/data

  atm10:
    container_name: atm10
    networks:
      minecraft-network:
        ipv4_address: 172.22.0.4
    image: itzg/minecraft-server
    environment:
      DIFFICULTY: hard
      MEMORY: 8G
      EULA: true
      MOD_PLATFORM: AUTO_CURSEFORGE
      CF_API_KEY: ${CF_API_KEY}
      CF_SLUG: all-the-mods-10
      CF_FORCE_SYNCHRONIZE: "true"
      CF_EXCLUDE_MODS: | # remove problematic client side mods
        lighty
        986380
      TYPE: NEOFORGE
      VERSION: 1.21
      NEOFORGE_VERSION: 21.0.167
    labels:
      - lazymc.enabled=true
      - lazymc.group=atm10
      # Point to the service name of the Minecraft server
      - lazymc.server.address=atm10:25565
      - lazymc.port=25566
      - lazymc.server.forge=true
      - lazymc.public.version=1.21
      - lazymc.public.protocol=767
    tty: true
    stdin_open: true
    restart: no
    volumes:
      - dataatm:/data

  vanilla:
    container_name: vanilla
    networks:
      minecraft-network:
        ipv4_address: 172.22.0.5
    image: itzg/minecraft-server
    environment:
      DIFFICULTY: hard
      MEMORY: 1G
      EULA: true
      TYPE: PURPUR
      VERSION: LATEST
    labels:
      - lazymc.enabled=true
      - lazymc.group=vanilla
      # Point to the service name of the Minecraft server
      - lazymc.server.address=vanilla:25565
      - lazymc.port=25567
      - lazymc.public.version=1.21
      - lazymc.public.protocol=767
    volumes:
      - vanilla:/data
volumes:
  databettermc:
  dataatm:
  vanilla:

also weird remark is that my current caddy setup doesnt really work with the port, i need to still specify the correct port when connecting via WAN. so fe. mc.mydomain.com:25567 works but just doing mc3.mydomain.com doesnt work. like it should when using the Caddy reverse proxy, but thats perhaps worth another issue 🤷 .
It then tries to turn on the wrong server. so packets are not going to the correct port/place.

  mc.mydomain.com {
        reverse_proxy *local_ip*:25565
}

mc2.mydomain.com {
        reverse_proxy *local_ip*:25566
}
vanilla.mydomain.com {
        reverse_proxy *local_ip*:25567
}

anonimised the caddyfile a bit