NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
22k stars 2.53k forks source link

invalid IPv6 address in resolver, scoped address, zone index #1015

Open JonasVgt opened 3 years ago

JonasVgt commented 3 years ago

I have made a Comment on a different Bug Report #149 but noticed later, that my problem was different to the one described there. That is why I made this separate Bug report.

The Problem

I am running this Docker Image on my Rapsberry Pi Home server. When I try to start the Container, it is marked as 'unhealthy', the web-interface will not start and the following error is repeatedly being logged:

nginx: [emerg] invalid IPv6 address in resolver "[fe80::abd:43ff:feca:7350%2]" in /etc/nginx/conf.d/include/resolvers.conf:1
finish: applet not found

Cause

When the Container is beeing started it will copy /etc/resolv.conf from the host machine (outside of the container) into the Container to the same location. The Content of that file will then be converted by the script located at nginx-proxy-manager/docker/rootfs/etc/services.d/nginx/run of this repository in the following line:

# Dynamically generate resolvers file, if resolver is IPv6, enclose in `[]`
# thanks @tfmm
echo resolver "$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf);" > /etc/nginx/conf.d/include/resolvers.conf

The output will then be written into /etc/nginx/conf.d/include/resolvers.conf. This file is read by nginx which will throw the error.

/etc/resolv.conf:

nameserver 8.8.8.8
nameserver fd00::3a10:d5ff:fe77:c05d
nameserver fe80::abd:43ff:feca:7350%2
search jonas.local

/etc/nginx/conf.d/include/resolvers.conf: resolver 127.0.0.11 [fd00::3a10:d5ff:fe77:c05d] [fe80::abd:43ff:feca:7350%2] ;

Note: fd00::3a10:d5ff:fe77:c05d is the IP of the Router which is connected to the Internet and directly to my Server via ethernet. fe80::abd:43ff:feca:7350 is the IP of a second Router which is only responsible for the WLAN in my Network

The Error emerges, because one of the IPs is ending with the zone index %2.

How to reproduce

Unfortunately I don't have any knowledge in this area and can't give an explanation on how to reproduce this behavior other than adding the IP address with zone index manually to the resolver of the host-machine. As stated before I have two Routers in my Network which might be the root cause of the Problem.

The Fix

A simple fix would be to edit the line which converts /etc/resolv.conf to /etc/nginx/conf.d/include/resolvers.conf so, that it will remove the zone index or the entire scoped IP. Unfortunately I am unable to find if nginx should handle these scoped IPs or if these IPs should even exist in /etc/resolv.conf. So this may fix a behavior which shouldn't even exist.

Setup

Device: Raspberry Pi 4B Operating System: Raspbian GNU/Linux 10 (buster) Docker:

Client: Docker Engine - Community
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:19:30 2021
 OS/Arch:           linux/arm
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:17:16 2021
  OS/Arch:          linux/arm
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Container: jc21/nginx-proxy-manager:latest

Thank you for the Help!

jc21 commented 3 years ago

Thanks for the detailed report. I don't see why we can't include that second address in the resolvers. Shouldn't be too hard to fix the regex.

github-actions[bot] commented 6 months ago

Issue is now considered stale. If you want to keep it open, please comment :+1:

xbingW commented 2 months ago

same error

nginx: [emerg] invalid IPv6 address in resolver "[fe80::46d9:e7ff:fe95:e3db%br0]" in /etc/nginx/nginx.conf:13