0

I'm trying to serve a static website from an EC2 instance using nginx. I'm also using Cloudflare as a CDN and DNS. The A record points to my instance's public IP while there's also a CNAME for www which resolves to the non-www domain.

The website works just fine with Chrome and curl but I get a connection error on Firefox and Safari.

This is the DNS configuration on Cloudflare: enter image description here And this is my website configuration:

server {

    listen 80;
    server_name www.duomov.com;
    client_max_body_size 100M;
    root /var/www/duomov/duomov-website;

    location / {
        try_files $uri $uri/ =404;
    }

    if ($http_x_forwarded_proto = "http") {
        return 301 https://$server_name$request_uri;
    }
}

server {
    server_name duomov.com;
    return 301 https://www.duomov.com$request_uri;
}

server {
    listen 443;
    server_name duomov.com;
    return 301 https://www.duomov.com$request_uri;
}
3
  • 1
    Are you sure it is not just because of outdated records in the DNS cache? You should provide a pcap file showing the connection failures.
    – kasperd
    Jun 10 '17 at 11:50
  • @kasperd I analysed the pcap and it seems that whenever I try to open the website with Safari or Firefox, the browser will try to connect to an IP belonging to my registrar. Could this be DNS cache? It's been 24 hours since I altered it and all the browsers are tested are on the same machine. I also tried clearing the local cache with a dscacheutil -flushcache
    – Raphael
    Jun 10 '17 at 12:08
  • I have no way of knowing what TTL the registrar may have used for those records. Also there are many layers at which caching could happen. The recursors you use, a local caching resolver on the machine, and even the browsers themselves. You should find the complete list of recursors which your machine is using and query each of those resolvers to see if they still have the old record and which TTL they are reporting.
    – kasperd
    Jun 11 '17 at 22:58
1

This is absolutely DNS cache issue. Try rebooting the machine to ensure all possible DNS caches are flushed. The CloudFlare configuration cannot cause one browser type to connect to IP A vs IP B -- that layer of the system is not aware of the difference.

On a side note, ensure that the IP in question is an Elastic IP as otherwise you will eventually lose it and your site will be down until a CloudFlare configuration change can propagate. Alternatively have CloudFlare point as a CNAME to an ELB that fronts your instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.