Question

Domain not working with nginx server setup

Posted April 17, 2020 1.8k views
Nginx

Hello,

I followed every steps from tutorial https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04#step-3-%E2%80%93-checking-your-web-server

I added dns to my domain provider,

  • ping to mydomain.com working
  • connecting to server using server ip from above tutorial working
  • added ufw rules But, when I type mydomain.com in chrome or firefox, it is just not responding at all. Could anyone help me to figure out what is the problem?

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

There are a couple of things you’ll need to check. Make sure you have created a configuration file for your domain mydomain.com in the /etc/nginx/sites-available/mydomain.com.

In there make sure you have the proper server block like so

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

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

        server_name mydomain.com www.mydomain.com;

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

Notice that you’ll need to change

        root /var/www/mydomain.com/html;

and

        server_name mydomain.com www.mydomain.com;

To the proper path and domain respectfully.

Once you have updated your configuration file, make sure to run

sudo ln -s /etc/nginx/sites-available/mydomain.com /etc/nginx/sites-enabled/

Again, remember to change your mydomain.com with the actual domain.

Lastly, check your Nginx configuration with

sudo nginx -t

If everything is okay restart nginx and everything should start working

service nginx restart

Regards,
KDSys

Submit an Answer