patrikm96
patrikm96

Reputation: 108

nginx configuration: IP address showing instead of domain name

I put my website on a DigitalOcean Droplet and it worked. I called the IP address and it showed me the address, then I forwarded the domain to the website IP and it connected it.

The issue at the beginning was that when I was accessing the website with my domain the access bar was showing my domain and when the page loaded it showed the IP address instead of the domain.

it seemed that the issue was in my nginx configuration, as I wrote just my IP address there.

```
server {
listen 80;
server_name 178.128.42.100;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
    root /home/patrik_website/patrik_web/form/;
}

location / {
    include proxy_params;
    proxy_pass http://unix:/run/gunicorn.sock;
}
}
```

I updated the file changing the server_name variable to: server_name patrikmuniak.com www.patrikmuniak.com; the lists in settings.py-ALLOWED_HOSTS=['*'] and after the update to the nginx website configuration, this it's been restarted with: sudo systemctl restart nginx the output is that when I use any browser and type the IP or the domain, now it shows me the page with 'Welcome to nginx!'.

The DNS records are: DNS records

and for forwarding I used the masking option.

if you need more info please let me know.

P.S. the OS is Ubuntu 19.04

Upvotes: 1

Views: 10860

Answers (1)

metallic
metallic

Reputation: 371

You should add your domain name to server name section:

server {
listen 178.128.42.100:80;
server_name domain_name.com www.domain_name.com;

And correct your dns records. You have to point @ to your ip: 178.128.42.100.

Upvotes: 2

Related Questions