nginx-proxy-manager icon indicating copy to clipboard operation
nginx-proxy-manager copied to clipboard

Host not working when using container's name with Podman

Open matheusfenolio opened this issue 3 years ago • 9 comments

Checklist

  • Have you pulled and found the error with jc21/nginx-proxy-manager:latest docker image?
    • Yes
  • Are you sure you're not using someone else's docker image?
    • Yes
  • Have you searched for similar issues (both open and closed)?
    • Yes

Describe the bug I'm trying to add a host using the name of the container, and when I open the URL, a 502 bad gateway appears. I tried using Docker, and it worked, but with Podman, it only works with container's IP.

Nginx Proxy Manager Version v2.9.18

To Reproduce Steps to reproduce the behavior:

  1. Create the container to forward: podman run --name web --network nginx-proxy-manager_default -d nginx:latest
  2. Add the host with: -Forward Hostname / IP: web -Port: 80
  3. Try to access service.

Expected behavior The Nginx welcome page should appear

Screenshots image

image

image

image

image

Operating System Tried on

  • Ubuntu 20.04 - Podman 3.2.2
  • Ubuntu 22.04 - Podman 3.2.2 and Podman 4.2
  • Fedora 36 - Podman 4.1

Additional context docker-compose.yml version: '3' services: app: image: 'jc21/nginx-proxy-manager:latest' restart: unless-stopped ports: - '80:80' - '81:81' - '443:443' volumes: - ./data:/data - ./letsencrypt:/etc/letsencrypt

matheusfenolio avatar Aug 12 '22 20:08 matheusfenolio

Don't think this is an NPM issue, there is lots of talk of podman issues around DNS after the default network change that was done for Podman 4 which was released in May of this year. Seems although CNI was left as the network stack if network was already setup, the DNS plugin was no longer used by default so this is the symptom. Try adding the DNS plugin to Podman for the old CNI network you probably have or remove the exisiting old network and upgrade to the new default network type which does have DNS builtin.

the1ts avatar Aug 13 '22 22:08 the1ts

I'll give it a shot! I saw some issues about it, but I thought it was fixed since I'm able to connect two containers only using the container name.

matheusfenolio avatar Sep 09 '22 17:09 matheusfenolio

whats strange is DNS works properly from command line, and even for creating subfolder proxies but not hostname proxies. hostnames will intermittently resolve which has me scratching my head even more.

BrandonG777 avatar Mar 29 '23 18:03 BrandonG777

Even using CNI network backend DNS is still intermittent. cannot replicate the issue at command line

BrandonG777 avatar Mar 30 '23 13:03 BrandonG777

Sorry, I don't use podman or npm anymore, but there is a good reason why command line and nginx work differently. DNS for the command line is done via podman or whatever is setting up the container. Nginx is setup to use /data/nginx/resolv.conf. This from memory gets set at first start and perhaps is incorrect or has multiple servers in it, hence intermittent.

the1ts avatar Mar 30 '23 14:03 the1ts

Well thanks for the reply anyway, you ultimately pointed me in the right direction. /data/nginx/resolv.conf no longer exist and didn't seem to have any affect on resolving this issue. However /etc/resolv.conf contained the podman host address and then my real host system dns entires. It appears that nginx was doing some sort of round robin selection of which DNS server it was going to use for lookup. Since this only affects host proxies and not subfolder location proxies I added a resolver entry to my host proxy custom config and that is working for me. I noticed the swag container uses 127.0.0.11 in it's resolver config which doesn't seem to work with this container. Maybe they are doing adding some sort of port forwarding or adding a package to make this work? Seems like that solution would work well for this container as well.

BrandonG777 avatar Mar 30 '23 19:03 BrandonG777

I believe I have tracked this down to a combination how nginx appears to handle the DNS resolution when it has multiple resolvers specified, and podman DNS resolution.

The issues can be resolved by manually altering the /etc/nginx/conf.d/include/resolvers.conf to only include the podman resolver ip, and no other ips. In my case:

# from
resolver 10.89.0.1 8.8.8.8 ipv6=off valid=10s;
# to
resolver 10.89.0.1 ipv6=off valid=10s;

This resolved my issues, obviously this wont stick through a container restart right now due to how this file is generated so as a more resilient interim solution I've added the updated resolvers line to the custom configs for proxies https://nginxproxymanager.com/advanced-config/#custom-nginx-configurations. Ideally I'd put it into the custom http.conf, however as nginx does not allow redeclaring directives, this wont work right now.

My proposal would be to allow a custom resolver config to be used on boot-up, and if it doesn't exist, then generate the file as it is right now.

fuzzyfox avatar Jul 19 '23 13:07 fuzzyfox

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

github-actions[bot] avatar Feb 12 '24 01:02 github-actions[bot]