AdguardTeam / AdGuardHome

Network-wide ads & trackers blocking DNS server
https://adguard.com/adguard-home.html
GNU General Public License v3.0
25.08k stars 1.8k forks source link

DNS Rewrite not working for AdGuard Home itself #7262

Open kikaragyozov opened 1 month ago

kikaragyozov commented 1 month ago

Prerequisites

Platform (OS and CPU architecture)

Linux, ARMv7

Installation

GitHub releases or script from README

Setup

On one machine

AdGuard Home version

latest

Action

After setting up successful DNS rewrite for my other services on my machine, I decided to setup a DNS rewrite for AdGuard home itself.

I wrote some domain, I made the target IP Address be the same like the other dns rewrites (i.e the machine IP, which starts with a 10, as it's in the private IP range), I've setup NGINX with literally 1:1 configuration which was completely successful for my other 2 applications, and voyla - after visiting my DNS server, I get a bogus 502 Gateway error.

The nginx configuration I've used for the other 2 applications, including for AdGuard Home, is the following:

server {
  listen 80;
  server_name my.adguard;

  # Disable access logging
  access_log off;

  # Disable error logging (optional)
  error_log /dev/null crit;

  location / {
      proxy_pass http://0.0.0.0:1234; # 1234 is where the web interface for AdGuard home lives, IP binding in .yaml of AdGuardhome is for 10.X.X.X
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;

      # Handle WebSocket connections, if any; Yes, I've tried disabling these - same thing.
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }
}

The only parts different in this configuration versus the others are obviously - the server_name and the port we forward to.

Expected result

Things to work.

Actual result

Things don't work.

Additional information and/or screenshots

No response

bcookatpcsd commented 1 week ago

Confused what you are looking for (sorry, trying to help)

https://www.f5.com/company/blog/nginx/using-nginx-as-dot-doh-gateway

Where is AGH the problem..