Nginx Proxy Manager fails to resolve localhost ip

1.8k Views Asked by At

Issue

My home server was working perfectly until yesterday.

I have an Nginx Proxy Manager to manage SSL (Let's Encrypt) with a duckdns domain that forward the requests to my home assistant that is hosted on the same server : NPM redirect to localhost.

Starting from yesterday evening, when I connect to the home server from outside, I get a "502 Bad Gateway openresty". I didn't change anything to the setup (maybe a reboot).

When I look a the logs, I have:

localhost could not be resolved (3: Host not found), client: 192.168.0.254 failed (111: Connection refused) while resolving, resolver: 127.0.0.1:53

Here is my docker compose file. Netwrok is host mode.

  nginx-proxy-manager:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    network_mode: host
    volumes:
      - /home/sigma/Server/nginx_proxy_man/data:/data
      - /home/sigma/Server/nginx_proxy_man/letsencrypt:/etc/letsencrypt

Here is my NPM redirection config extracted from NPM files:

server {
  set $forward_scheme http;
  set $server         "localhost";
  set $port           8123;

  listen 80;
listen [::]:80;

listen 443 ssl http2;
listen [::]:443 ssl http2;


  server_name domain.duckdns.org;


  # Let's Encrypt SSL
  include conf.d/include/letsencrypt-acme-challenge.conf;
  include conf.d/include/ssl-ciphers.conf;
  ssl_certificate /etc/letsencrypt/live/npm-2/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/npm-2/privkey.pem;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;

  access_log /data/logs/proxy-host-1_access.log proxy;
  error_log /data/logs/proxy-host-1_error.log warn;

  location / {

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;

    # Proxy!
    include conf.d/include/proxy.conf;
  }

  # Custom
  include /data/nginx/custom/server_proxy[.]conf;
}

What I tried

I tried to replace localhost by 127.0.0.1 in NPM configuration and it works. It works because I solve the issue for him, localhost don't need to be resolved anymore => no issue

I checked my /etc/hosts file (that I didn't change) and it seems good for me :

127.0.0.1       localhost
127.0.1.1       sigma-server

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters 

Question

Do you know what happened suddenly.

What can I check to solve the issue properly ?

0

There are 0 best solutions below