Adguard integration behind a Traefik reverse proxy

I’ve got a Docker server in which both HA and several other apps including Adguard are installed in containers. When I try to set up the Adguard integration it can’t connect to my Adguard instance, with the below error in my logs.

Basically, Traefik reverse proxies Adguard such that I can go to https://adguard.mydomain.com to interact with it. During setup the installer for Adguard changed itself to port 80 and my Traefik labels represent that. I can use Adguard itself just fine (53 is directly exposed for DNS). The domain is a real one with a valid LE SSL certificate and I have DNS entries set up in Adguard so that my clients point to the internal lan IP address.

I’m not sure what is happening. It could be trying to connect to port 3000 despite having a port field which might result in the 404 error. Any help is appreciated.

Config screen for the intergation:

Traefik log (included for thoroughness, from another attempt):

172.27.0.1 - - [30/May/2021:17:14:54 +0000] "GET /control/status HTTP/1.1" - - "-" "-" 86 "-" "-" 0ms
192.168.1.221 - - [30/May/2021:17:14:54 +0000] "POST /api/config/config_entries/flow/d73ab95d89a945b6a0ebb25797066d92 HTTP/2.0" 500 55 "-" "-" 85 "[email protected]" "http://172.27.0.4:8123" 7ms

Home Assistant log:

Logger: aiohttp.server
Source: components/adguard/config_flow.py:93
First occurred: 12:35:13 AM (36 occurrences)
Last logged: 2:27:09 AM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 74, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 135, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 131, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 155, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 63, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 109, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 199, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 257, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/adguard/config_flow.py", line 93, in async_step_user
    await adguard.version()
  File "/usr/local/lib/python3.8/site-packages/adguardhome/adguardhome.py", line 223, in version
    response = await self.request("status")
  File "/usr/local/lib/python3.8/site-packages/adguardhome/adguardhome.py", line 164, in request
    raise AdGuardHomeError(
adguardhome.exceptions.AdGuardHomeError: (404, {'message': '404 page not found\n'})

As soon as I typed this all out and submitted I thought hey, lets try port 443 and of cause it now works.

Ah well, thanks for reading anyway. :grin:

I’m having a problem almost like yours … Can you share your docker-compose.yaml?

I got the same Setup:
2 times AdGuard Home behind Traefik Reverse Proxy on 2 Raspberry Pis to protect my home network.

I can confirm that port 443 works (as long you are using HTTPS/SSL:

Host: adguard.my-local-domain.lan
Port: 443

If you’ve got it setup in docker-compose you could probably route to the adguard container directly from home assistant without going through ‘my domain.com’. e.g. by using the adguard container name as the host address, or by pointing the host address to 0.0.0.0 and the port to the one exposed by adguard.

(that last option is the one I chose)