Question

Domain name - ip configuration

Hi,

I have very little experience in using nginx and this may be a trivial question. I have configured the NS records on my registrar’s site to use my domain for the site I’m hosting on DigitalOcean. On the DNS records on DigitalOcean there are 3 NS records and 1 A record that points to my IP as it does by default. I have also added an “A” record with “www” to point to same IP.

Now, when I open my IP on the browser I can see my site, however the domain names “example.com” and “www.example.com” show the “Welcome to nginx” page. I believe my domain points to the correct IP, but I think I am missing something in the nginx side. Any help is appreciated.

My sites-avalable/web_project contents:

server {
    listen 80;
    server_name 159.65.127.239;
    root /home/mehmet/project;
 
    location /static/ {
    }
 
    location /media/ {
    }
 
    location / {
        include proxy_params;
        proxy_pass http://unix:/home/mehmet/project/web_project.sock;
    }
}

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.

baraboom
DigitalOcean Employee
DigitalOcean Employee badge
January 14, 2021
Accepted Answer

Hi! If you’re sure that the DNS is resolving correctly, it looks like you need to update your nginx config so that it will recognize your domains.

In your posted example, you have server_name set to an IP address. Instead, a configuration like this should work better:

server {
    . . .
    server_name example.com www.example.com;
    . . .
}

Reference here:

How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 16.04

Hope this helps and good luck!

Try DigitalOcean for free

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

Sign up

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
DigitalOcean Cloud Control Panel