I am using a Docker droplet and I am trying to configure Nginx as a reverse proxy. When I type my IP in the browser I can see the HTML my page, but when I use my domain (mydomain.com) it doesn’t work. I notice that with Postman I can make a GET request HTTPand it loads the HTML page, on browser always try to use an HTTPSconnection.

Here is my nginx.conf:

server {
    listen 80;
    listen [::]:80;
    listen 443;
    listen [::]:443;

    server_name iamgonzales.dev www.iamgonzales.dev;

    location ~ /.well-known/acme-challenge {
        allow all;
        root /usr/share/nginx/html;
    }

    root /usr/share/nginx/html;
    index index.html;
}

Here is my docker-compose.yml

version: '3.1'

services:

  letsencrypt-nginx-container:
    container_name: 'letsencrypt-nginx-container'
    image: nginx:latest
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
      - ./letsencrypt-site:/usr/share/nginx/html
    networks:
      - docker-network

networks:
  docker-network:
    driver: bridge


Here are all my droplet open doors:

root@docker:~# netstat -tulpn | grep LISTEN
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      740/systemd-resolve
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      951/sshd
tcp6       0      0 :::80                   :::*                    LISTEN      5412/docker-proxy
tcp6       0      0 :::22                   :::*                    LISTEN      951/sshd
tcp6       0      0 :::443                  :::*                    LISTEN      5400/docker-proxy

Is there any conf that I missing??

Appreciate any help as I lost half day on this.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi, @stgonzales

Before we deep dive into troubleshooting this, can you confirm that the domain name is pointed to your droplet’s IP address?

You can use our DNS lookup tool in order to check if the domain name is resolving from your droplet:

https://www.digitalocean.com/community/tools/dns

Let me know how it goes,

Regards,
Alex

  • Yes @alexdo, my domain name is pointed to your droplet’s IP address, here’s the result.

    Name TTL Data
    mydomain.com 3600 IPaddr
    Owner: DIGITALOCEAN-209-97-128-0
    edited by alexdo
    • Hi,

      Looking at this both the domain name and the IP address are loading the same page:

      “Oh, hai there!
      This is the temporary site that will only be used for the very first time SSL certificates are issued by Let’s Encrypt’s certbot.”

      Could you please let me know if you’re sorted the issue?

      Regards,
      Alex

      • Hi,

        No, if you type on your browser (Chorme, Mozilla, etc) http://mydomain.com/, it changes to httpS and I get a message:

        This site can’t be reached
        mydomain.com refused to connect.

        Because of this, I can’t use obtain letsencrypt an automated certificate, returns me a 404. The point is if I try http://mydomain.com/ with Postman, it works.

        letsencrypt error message:

        IMPORTANT NOTES:
         - The following errors were reported by the server:
        
           Domain: iamgonzales.dev
           Type:   unauthorized
           Detail: Invalid response from
           http://iamgonzales.dev/.well-known/acme-challenge/sOG2-XmdsZrJaNnORb7BV1EKwugogBWUwaIeOVn14iI
           [209.97.131.52]: "<html>\r\n<head><title>404 Not
           Found</title></head>\r\n<body>\r\n<center><h1>404 Not
           Found</h1></center>\r\n<hr><center>nginx/1.19.1</ce"
        
           To fix these errors, please make sure that your domain name was
           entered correctly and the DNS A/AAAA record(s) for that domain
           contain(s) the right IP address.
         - The following errors were reported by the server:
        
           Domain: www.iamgonzales.dev
           Type:   dns
           Detail: DNS problem: NXDOMAIN looking up A for www.iamgonzales.dev
           - check that a DNS record exists for this domain
        
        
      • nginx docker container log:

        52.28.236.88 - - [25/Jul/2020:08:32:29 +0000] "GET /.well-known/acme-challenge/sOG2-XmdsZrJaNnORb7BV1EKwugogBWUwaIeOVn14iI HTTP/1.1" 404 153 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)" "-"
        52.15.254.228 - - [25/Jul/2020:08:32:29 +0000] "GET /.well-known/acme-challenge/sOG2-XmdsZrJaNnORb7BV1EKwugogBWUwaIeOVn14iI HTTP/1.1" 404 153 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)" "-"
        34.222.229.130 - - [25/Jul/2020:08:32:29 +0000] "GET /.well-known/acme-challenge/sOG2-XmdsZrJaNnORb7BV1EKwugogBWUwaIeOVn14iI HTTP/1.1" 404 153 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)" "-"
        64.78.149.164 - - [25/Jul/2020:08:32:29 +0000] "GET /.well-known/acme-challenge/sOG2-XmdsZrJaNnORb7BV1EKwugogBWUwaIeOVn14iI HTTP/1.1" 404 153 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)" "-"
        
Submit an Answer