Run hass in host mode with traefik with own domain

I bought a new small homeserver, an Intel Nuc.
Just started building a new entire config for home automation, including Home Assistant.

I used this and this great guides for setting it up with Ubuntu, docker-compose and Traefik with my own domain, because I’m just a Linux noob. I have a working config, until now.

Changed the config a little in my docker-compose.yml and traefik.toml files; I want to use discovery from Hass, and so I need to use network_mode = host.
But now, I cannot reach Hass from the UI anymore, I only get the hass login screen, and it says “unable to connect to Home Assistant”, retry results in a Traefik 404 page.

I put parts of my docker-compose.yml and traefik.toml file here:

  homeassistant:
    image: homeassistant/home-assistant
    container_name: homeassistant
    hostname: homeassistant
    restart: always
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0
      - /dev/ttyUSB1:/dev/ttyUSB1
      - /dev/ttyACM0:/dev/ttyACM0
#    networks:
#      - traefik_proxy
#      - default
#    ports:
#      - "XXXX:8123"
    privileged: true
    environment:
      PUID: ${PUID}
      PGID: ${PGID}
      TZ: ${TZ}
    volumes:
      - ${USERDIR}/docker/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
      - ${USERDIR}/docker/shared:/shared
    network_mode: host  
#    labels:
#      traefik.enable: "true"
#      traefik.backend: homeassistant
#      traefik.protocol: http
#      traefik.port: 8123
#      traefik.frontend.rule: Host:hass.${DOMAINNAME}
#      traefik.frontend.headers.SSLHost: hass.${DOMAINNAME}
#      traefik.docker.network: traefik_proxy
#      traefik.frontend.passHostHeader: "true"
#      traefik.frontend.headers.SSLForceHost: "true"
#      traefik.frontend.headers.SSLRedirect: "true"
#      traefik.frontend.headers.browserXSSFilter: "true"
#      traefik.frontend.headers.contentTypeNosniff: "true"
#      traefik.frontend.headers.forceSTSHeader: "true"
#      traefik.frontend.headers.STSSeconds: 315360000
#      traefik.frontend.headers.STSIncludeSubdomains: "true"
#      traefik.frontend.headers.STSPreload: "true"
#      traefik.frontend.headers.customResponseHeaders: X-Robots-Tag:noindex,nofollow,nosnippet,noarchive,notranslate,noimageindex
#      traefik.frontend.headers.frameDeny: "true"
#      traefik.frontend.headers.customFrameOptionsValue: 'allow-from https:${DOMAINNAME}'
[file]
  watch = true
  filename = "/etc/traefik/rules.toml"
[backends]
  [backends.backend-homeassistant]
    [backends.backend-homeassistant.servers]
      [backends.backend-homeassistant.servers.server-homeassistant-ext]
        url = "http://172.17.0.1:8123"
        weight = 0

[frontends]
  [frontends.frontend-homeassistant]
    backend = "backend-homeassistant"
    passHostHeader = true
    [frontends.frontend-homeassistant.routes]
      [frontends.frontend-homeassistant.routes.route-homeassistant-ext]
      rule = "Host:hass.domain.nl"

Without host mode, it works well, exept auto discovery. I guess there is something wrong with my docker-compose of traefik.toml file,

Were you able to solve this problem?
I have exactly your problems