I set up my first server on a digital ocean droplet two months ago. The website operates great under ‘site.com’(this is not the actual address…). However, you can no longer access it with ’www.site.com’. I set up certbot, and that worked at the time of set up, but it is having issues now, second to the DNS issue.

All of this goes to say, I can not figure out why it is failing to work with www, when it allowed me to use it last month.

I have an A Record for the domain itself, and then a CNAME with www as an alias of the domain. My assumption is that the server details may be incorrect. A related stack overflow thread suggested that you need a separate server detail in the same file set up with server_name as www.

Currently, this is what I have (The latter details of the server are left out after the server name):


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

        root /var/www/site.com/html;
        index index.html index.htm index.nginx-debian.html;

        server_name site.com www.site.com;

The location block and certbot info follows if that is applicable.
This is how it is shown in the digital ocean docs that I read.

I tried checking the nginx logs, and the access logs work fine. The error log is clear of anything, so either it doesn’t work, or there are no errors.

Again, this is my first server/site, so I am open to any stupid and obvious mistakes that you can think of. I appreciate it!

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 @benwed,

Can you post your whole server block? At the moment what I see look okay but still want to be sure.

If have mentioned you can’t see any errors, this leads me to believe that your www record is not actually working properly.

If you ping your www domain

ping www.domain.com

Where domain.com is your really domain, what does it return, do you see your droplet’s IP address or something else?

Regards,
KFSys

  • Thanks for your response. The full server block looks as follows:

    server {
            listen 80;
            listen [::]:80;
    
            root /var/www/mcminnclinic.com/html;
            index index.html index.htm index.nginx-debian.html;
    
            server_name mcminnclinic.com www.mcminnclinic.com;
    
            location / {
            proxy_pass http://localhost:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }
    
        listen [::]:443 ssl ipv6only=on; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/mcminnclinic.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/mcminnclinic.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    
    }
    

    I tried to ping with www, and it said name or service not known. I do believe the issue is on the DNS end, but I can’t figure out what to change to make it work. I have tried many suggestions, but it fails to propagate with a WWW A record pointing to the IP, and also fails as a CNAME as an alias of @. Any suggestions are appreciated!

    • Hi @benwed,

      I pinged the domain as well, it does seem like the issue is connected to DNS rather than your droplet.

      I can see your nameservers are with GOdaddy if I’m not mistaken. You’ll need to update your records there. Setting an A record for www should be fine.

Submit an Answer