Question

Domain name stopped resolving to VPS

I have DO VPS running on Cent OS 7. I installed nginx and Virtual min. I am not able to resolve my domain to the VPS. I have created a A record pointing to my Floating IP(static IP) in cloudflare and a CNAME www with a value @. I used the same settings before, it was working. I destroyed my droplet and built a new on but I have assigned the same static IP to the VPS. I have allowed ports 80,443 and 10000.

I have configured my nginx.conf to listen on port 443 too. But still it my domain name does not resolve to my VPS. Here is my nginx.conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile            on;
tcp_nopush          on;
tcp_nodelay         on;
keepalive_timeout   65;
types_hash_max_size 2048;

include             /etc/nginx/mime.types;
default_type        application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
    }

    # Settings for a TLS enabled server.
    #
    #    server {
    #        listen       443 ssl http2 default_server;
    #        listen       [::]:443 ssl http2 default_server;
    #        server_name  _;
    #        root         /usr/share/nginx/html;
    #
    #        ssl_certificate "/etc/pki/nginx/server.crt";
    #        ssl_certificate_key "/etc/pki/nginx/private/server.key";
    #        ssl_session_cache shared:SSL:1m;
    #        ssl_session_timeout  10m;
    #        ssl_ciphers HIGH:!aNULL:!MD5;
    #        ssl_prefer_server_ciphers on;
    #
    #        # Load configuration files for the default server block.
    #        include /etc/nginx/default.d/*.conf;
    #
    #        location / {
    #        }
    #
    #        error_page 404 /404.html;
    #            location = /40x.html {
    #        }
    #
    #        error_page 500 502 503 504 /50x.html;
    #            location = /50x.html {
    #        }
    #    }

     server_names_hash_bucket_size 128;
     server {
     server_name mydomain.com www.mydomain.com;
     listen 174.138.xxx.x;
     root /home/mydomain/public_html;
     index index.html index.htm index.php;
     access_log /var/log/virtualmin/mydomain.com_access_log;
     error_log /var/log/virtualmin/mydomain.com_error_log;
     fastcgi_param GATEWAY_INTERFACE CGI/1.1;
     fastcgi_param SERVER_SOFTWARE nginx;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT /home/mydomain/public_html;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param HTTPS $https;
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/php-nginx/152112218423330.sock/socket;
    }
    listen 174.138.xxx.x:443 ssl;
    server_name mydomain.com www.mydomain.com;
    ssl_certificate /home/mydomain/ssl.cert;
    ssl_certificate_key /home/mydomain/ssl.key;
    fastcgi_read_timeout 60;
    gzip on;
  
    }
    }

I tried checking if the ports are listening using netstat -an | grep 443 | grep -i listen and they seem to be listening. Here is my output

tcp        0      0 174.138.xxx.x:443       0.0.0.0:*                     LISTEN

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted Answer

You had a few duplicate entries as well mis configured entries - try this - run sudo nginx -t before you restart your NGINX server and it will let you know if any errors are present.

user nginx;

worker_processes auto;

error_log /var/log/nginx/error.log;

pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
  worker_connections 1024;
}

http {
  
  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';
  
  access_log  /var/log/nginx/access.log  main;
  
  sendfile            on;
  tcp_nopush          on;
  tcp_nodelay         on;
  keepalive_timeout   65;
  types_hash_max_size 2048;
  
  include             /etc/nginx/mime.types;
  default_type        application/octet-stream;
  
  include /etc/nginx/conf.d/*.conf;
  

  server {
    
    listen       80 default_server;
    listen       [::]:80 default_server;
    
    server_name  mydomain.com www.mydomain.com;
    
    root         /usr/share/nginx/html;
  
    include /etc/nginx/default.d/*.conf;
  
    location / {
        
    }
  
    error_page 404 /404.html;
        location = /40x.html {
    }
  
      error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
  }
     
  server {
     
    listen 443 ssl;
    
    server_name mydomain.com www.mydomain.com;
     
     
    root /home/mydomain/public_html;
    index index.php index.html index.htm;
    
    access_log /var/log/virtualmin/mydomain.com_access_log;
    
    error_log /var/log/virtualmin/mydomain.com_error_log;

    
    location ~ \.php$ {
      try_files $uri =404;
      fastcgi_pass unix:/var/php-nginx/152112218423330.sock/socket;
      
      fastcgi_param GATEWAY_INTERFACE CGI/1.1;
      fastcgi_param SERVER_SOFTWARE nginx;
      fastcgi_param QUERY_STRING $query_string;
      fastcgi_param REQUEST_METHOD $request_method;
      fastcgi_param CONTENT_TYPE $content_type;
      fastcgi_param CONTENT_LENGTH $content_length;
      fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html$fastcgi_script_name;
      fastcgi_param SCRIPT_NAME $fastcgi_script_name;
      fastcgi_param REQUEST_URI $request_uri;
      fastcgi_param DOCUMENT_URI $document_uri;
      fastcgi_param DOCUMENT_ROOT /home/mydomain/public_html;
      fastcgi_param SERVER_PROTOCOL $server_protocol;
      fastcgi_param REMOTE_ADDR $remote_addr;
      fastcgi_param REMOTE_PORT $remote_port;
      fastcgi_param SERVER_ADDR $server_addr;
      fastcgi_param SERVER_PORT $server_port;
      fastcgi_param SERVER_NAME $server_name;
      fastcgi_param HTTPS $https;
      fastcgi_read_timeout 60;   
    }
    
    ssl on;
    ssl_certificate /home/mydomain/ssl.cert;
    ssl_certificate_key /home/mydomain/ssl.key;
    
    gzip on;

  }
}

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more