Score:0

Docker containers not accessible from internet (using jwilder's nginx+letsencrypt solution)

cn flag

I have been using the jwilder's nginx + letsencrypt solution to access my containers online.

Last week my server crashed and after a restart, I couldn't access any of my containers from the internet. Accessing them from LAN works but I get "refused to connect" errors when I use the web address (I'm using DDNS with a domain I own).

Checking the logs, I immediately saw errors in letsencrypt logs like: :Verify error:: Fetching http:///.well-known/acme-challenge/oSGmRMyB-df4XEN3ZW-8ksBvtxxO8m2Di50mhpWWuu8: Connection refused

I have already double checked port forwarding on my Router and things seem to be ok. I can even use port 22 to SSH into my machine, just to validate that the port forwarding is working.

I also checked UFW status, thinking of firewall issues on my server and UFW is inactive as well.

Any suggestions on how can I debug this further?

Edit: I did an nmap on my server's local IP. I can see that all the container ports are open but the nginx ports 80 and 443 are closed. I'm now at a loss how to ensure the nginx docker container can open this port. Here's my docker-compose :


services:
  nginx:
    image: jwilder/nginx-proxy:latest
    container_name: nginx
    restart: always
    labels:
      com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: 'true'
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./data//htpasswd:/etc/nginx/htpasswd
      - ./data/certs:/etc/nginx/certs:ro
      - ./data/conf.d:/etc/nginx/conf.d
      - ./data/vhost.d:/etc/nginx/vhost.d
      - ./data/html:/usr/share/nginx/html
      - /var/run/docker.sock:/tmp/docker.sock:ro
    networks:
      - proxy

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion:latest
    container_name: letsencrypt_multi
    restart: always
    volumes:
      - ./data/vhost.d:/etc/nginx/vhost.d
      - ./data/certs:/etc/nginx/certs:rw
      - ./data/html:/usr/share/nginx/html
      - /var/run/docker.sock:/var/run/docker.sock:ro
    depends_on:
      - nginx
    networks:
      - proxy

networks:
  proxy:
    driver: bridge
Score:0
cn flag

If someone else is facing the issue, I found the solution.

In one of my containers that I was exposing through the nginx reverse proxy, I had commented out the "VIRTUAL_HOST" environment variable to stop internet access to the container. I had however, forgotten to comment out "VIRTUAL_PORT" and this was leading to errors in the default.conf for nginx. When I restarted nginx, I was getting parse errors for default.conf invalid number of arguments in "upstream" directive

The offending entry was pointing to the container which had the above mentioned misconfiguration, fixing that and restarting the container and subsequently nginx resolved the problem for me.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.