Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPv6 not supported #149

Closed
epelaez1 opened this issue May 24, 2019 · 10 comments
Closed

IPv6 not supported #149

epelaez1 opened this issue May 24, 2019 · 10 comments
Labels

Comments

@epelaez1
Copy link

epelaez1 commented May 24, 2019

Describe the bug

  • Seems like IPv6 is not supported.
  • Versions used: Latests

To Reproduce
Steps to reproduce the behavior:

  1. Enable IPv6 for docker:
  • Create a network at docker with the following command:
    $ docker network create --subnet 2a02::/80 --ipv6 network_name
    Replace 2a02:: with the IPv6 block given by your ISP, or, in case you don't have IPv6 support use a block reserved for NAT, (for example: fe80:10::/80). I will use 2a02:10::/80 in this example.
  1. Create the dockers:
  • Create the docker of mariadb inside that network:
    $ docker pull mariadb
    $ docker create --name=mariadb -e MYSQL_ROOT_PASSWORD=your_password -v ~/docker_data/mariadb:/var/lib/mysql --network network_name --ip6 2a02:10::10 mariadb
    $ docker start mariadb
  • Create a database called nginx:
    $ docker run -it --network network_name --rm mariadb mysql -hmariadb -uroot -p
    Enter your password
    MariaDB [(none)]> CREATE DATABASE nginx;
  • Edit the config.json file.
  • Create the nginx proxy manager docker:
    $ docker pull jc21/nginx-proxy-manager:latest
    $ docker create --name=reverse_proxy --restart unless-stopped -v ~/docker_data/proxy/config.json:/app/config/production.json -v ~/docker_data/proxy/data:/data -v ~/docker_data/proxy/letsencrypt:/etc/letsencrypt --network network_name --ip6 2a02:10::11 jc21/nginx-proxy-manager
    $ docker start reverse_proxy
  1. Everything should work until this point.

  2. Access the web ui with Google Chrome using the IPv6 address of the docker.
    http://[2a02:10::11]:81

  3. Try to login with admin@example.com and changeme as credentials.
    The web responds with an Internal Error. And if you check the logs of the docker you should see the following message:
    [Express ] › ⚠ warning data should match pattern "^[a-z\-]+:\/\/(?:[\w\-\.]+(:[0-9]+)?/?)?$"

  4. Now restart the docker:
    $ docker stop reverse_proxy
    $ docker start reverse_proxy
    And now the following error apears:
    [emerg] 320#320: invalid port in resolver "fe80::something%2" in /etc/nginx/conf.d/include/resolvers.conf:1 nginx: [emerg] invalid port in resolver "fe80::something%2" in /etc/nginx/conf.d/include/resolvers.conf:1
    Beeing fe80::something the local IPv6 of the docker created before.

Operating System

  • Ubuntu Server

Important comments about IPv6
In order to get access from outside the host you probably need to run the following commands:

(Replace eth0 with your network adapter name (see ifconfig))
(Replace 2a02:10::11 with the address used for the container)
$ sysctl net.ipv6.conf.eth0.accept_ra=2
$ sysctl net.ipv6.conf.eth0.proxy_ndp=1
$ ip -6 neigh add proxy 2a02:10::11 dev eth0

If you are using a local IPv6 block (fe80::/80) you don't need this commands.

I know that IPv6 is not an easy thing to work with but I hope you can fix this bug.

@epelaez1 epelaez1 added the bug label May 24, 2019
jc21 added a commit that referenced this issue Apr 7, 2020
- Added ipv6 listening to hosts when configured, fixes #236 and #149
- Added documentation about disabling ipv6
- Updated npm packages
@jc21
Copy link
Member

jc21 commented Apr 7, 2020

Resolved in v2.2.2

@jc21 jc21 closed this as completed Apr 7, 2020
@PKizzle
Copy link

PKizzle commented Apr 13, 2020

I still receive the mentioned Internal Error when trying to access the web ui using IPv6. However the IPv6 configuration is valid and works for other docker containers. Accessing the UI via IPv4 works without any issues.

The ajax request to /api/tokens seems to be the issue. It returns an error code 400.

@jc21
Copy link
Member

jc21 commented Apr 13, 2020

That's strange - if you can inspect the files inside your running docker container, specifcally /etc/nginx/conf.d/production.conf the configuration should mention listen [::]:81 default; without a preceding comment.

Are you accessing the admin interface directly on port 81 or do you have it behind a Proxy Host?

@PKizzle
Copy link

PKizzle commented Apr 13, 2020

This is the content of the file you mentioned:

# Admin Interface
server {
	listen 81 default;
	listen [::]:81 default;

	server_name nginxproxymanager;
	root /app/frontend;
	access_log /dev/null;

	location /api {
		return 302 /api/;
	}

	location /api/ {
		add_header            X-Served-By $host;
		proxy_set_header Host $host;
		proxy_set_header      X-Forwarded-Scheme $scheme;
		proxy_set_header      X-Forwarded-Proto  $scheme;
		proxy_set_header      X-Forwarded-For    $remote_addr;
		proxy_pass            http://127.0.0.1:3000/;
	}

	location / {
		index index.html;
		if ($request_uri ~ ^/(.*)\.html$) {
			return 302 /$1;
		}
		try_files $uri $uri.html $uri/ /index.html;
	}
}

I am directly accesing the admin UI without any proxy http://[${IPV6_ADDR}]:81/login

This is the response from the ajax request to /api/tokens:
{"error":{"code":400,"message":"Internal Error"}}

@jc21
Copy link
Member

jc21 commented Apr 13, 2020

So the docker logs for that container should have some more info about the internal error?

@jc21
Copy link
Member

jc21 commented Apr 14, 2020

Fix the login, it was a cors issue which wasn't expecting a ipv6 address in the referring url.

jc21 added a commit that referenced this issue Apr 14, 2020
Support ipv6 address as a origin header, hopefully fixes #149
@jc21
Copy link
Member

jc21 commented Apr 14, 2020

Pull the latest or 2.2.2 or 2 images to get this fix.

@PKizzle
Copy link

PKizzle commented Apr 14, 2020

Thank you very much. The issue is now fixed.

@JonasVgt
Copy link

I have a very similar Problem. but pulling latest, 2.2.2, 2 doesn't seem to help.
When using only ipv4, there is no Problem but when creating a docker-network with
sudo docker network create --ipv6 --subnet fd12:3456:789a:1::/64 --subnet 172.23.0.0/16 nginx_default --attachable
and then running docker-compose with the following file:


version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    ports:
      - '80:80' #http traffic
      - '81:81' #dashboard
      - 443:443 #https traffic
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "<USER>"
      DB_MYSQL_PASSWORD: "<PASS>"
      DB_MYSQL_NAME: "nginx"
      DISABLE_IPV6: 'false'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    restart: always
  db:
    image: 'yobasystems/alpine-mariadb:latest'
    environment:
      MYSQL_ROOT_PASSWORD: '<ROOT_PASS>'
      MYSQL_DATABASE: 'nginx'
      MYSQL_USER: '<USER>'
      MYSQL_PASSWORD: '<PASS>'
    volumes:
      - /srv/dev-disk-by-uuid-3fc1b3a4-7cc8-4262-ab30-8611d1e40119/Databases/nginx:/var/lib/mysql
    restart: always

networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: "fd12:3456:789a:1::/64"

the webinterface doesn't start, the app is marked as 'unhealthy' and it produces this Error in the log files:

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

The weird thing is, that this used to work without problems two days ago, but after restarting the server the error emerged.
I am running Raspbian GNU/Linux 10 (buster) on a Raspberry Pi 4B.
I have tried fixing the problem now for a few hours without luck.

@JonasVgt
Copy link

I did some a little bit more research. I don't really know what I am talking about but here is what I found.
The Problem seems to be, that somehow /etc/resolv.conf inside the container looks like this:

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

I Think this file is copied from the file /etc/resolv.conf from outside the container when creating the container and then converted to /etc/nginx/conf.d/include/resolvers.conf which looks like this:
resolver 127.0.0.11 [fd00::3a10:d5ff:fe77:c05d] [fe80::abd:43ff:feca:7350%2]
And that's where the problem lies, because nginx doesn't seem to like, that there is a %2at the end of one ip-address.

As I said before I don't really know, how that %2 came into the resolv.conf file in the first place, but I will try to figure that out.

This Problem might be fixed by changing the conversion from the resolv.conf to resolvers.conf. in the file
nginx-proxy-manager/docker/rootfs/etc/services.d/nginx/run of this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants