What鈥檚 the configuration suppose to be like for a Nginx reverse proxy?
This works fine for me
location /adguard/ { #trailing slash is necessary, use any path you want
proxy_set_header Host $http_host; #not necessary but recommended
proxy_redirect off; #not necessary but recommended
proxy_pass https://domain:8443/; #8443 is the https port I use, make sure to change that to the port AGH is listening on. Change "https" to "http" if necessary. The trailing slash is also needed here.
proxy_http_version 1.1; #not necessary but recommended
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #not necessary but recommended
}
You can also reverse proxy DOH queries by using this location block
location /dns-query { #no trailing slash, use any path you want
proxy_pass https://domain:8443/dns-query; #no trailing slash, "https" is necessary
proxy_http_version 1.1; #allows keepalive connections which will reduce latency
proxy_set_header Host $http_host; #same as above
proxy_buffering off; #to reduce latency
proxy_redirect off; #same as above
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #same as above
}
Thanks for the help!
Unfortunately, that didn't seem to work. I'm still getting a 502 Bad Gateway from the reverse proxy. Port number still works.
Here is the error log from Nginx
2019/08/21 13:44:55 [error] 14276#14276: *147 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: example.com, request: "GET /adguard/ HTTP/1.1", upstream: "https://127.0.0.1:3443/", host: "example.com", referrer: "https://example.com/adguard/"
in proxy-pass did you put 127.0.0.1 or your actual domain?
I put 127.0.0.1 because Nginx and AdGuardHome is on the same machine and network. I changed it to the local ip of the machine and it worked! Not for sure why??
Yeah I put my domain into the proxy-pass section and it worked perfectly. The strangest thing is that in the query log, it clearly shows 127.0.0.1 as the source. I also have no idea why 127.0.0.1 doesn't work.
Thanks for the help!
@adriancleung
I have solved it! Need to proxy static resources, please refer to the following configuration file:
# Proxy AdGuard Home
#
server {
listen 443 ssl http2;
server_name {your domain name};
ssl_certificate {your domain name crt};
ssl_certificate_key {your domain name key};
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location / {
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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_pass http://127.0.0.1:8080;
}
location ~ .*.(gif|jpg|jpeg|png|bmp|swf|css|js)$ {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
I'm not quite sure if my issue is related but even if I get proxied correctly to the AdGyardHome login page I see a blank page with the console reporting ERR_BLOCKED_BY_CLIENT.
Did any of you had this issue initially?
Did any of you had this issue initially?
Most likely this is some browser extension that is blocking the request.
Most helpful comment
Most likely this is some browser extension that is blocking the request.