Nginx: No such file or directory

Viewed 2148

I have a vps server by Reg.ru and domain by freenom.

On the Reg.ru I added domain via dnsadmin. All right. Notes are created. Status - synchronized.

On the freenom in the management panel of domain are next fields: Name, Type, TTL, Target. Name - empty, TTL - 3600, Type - A, Target - ip of vps server. Status - active.

Nginx

/etc/nginx/sites-available/myproject and /etc/nginx/sites-enabled/myproject

server {
  listen 80;
  server_name example.com;
  location = /favicon.ico { access_log off; log_not_found off; }
  location /static/ {
    root /home/myproject;
  }
  location / {
    include proxy_params;
    proxy_pass http://unix:/run/gunicorn.sock;
  }
}

/etc/nginx/nginx.conf

...
http {
    ...
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*.*;
}

nginx -t - successful

systemctl status nginx - active

ufw status

Status: active

To                         Action      From
--                         ------      ----
8000                       ALLOW       Anywhere                  
80                         ALLOW       Anywhere                  
443                        ALLOW       Anywhere                  
8000 (v6)                  ALLOW       Anywhere (v6)             
80 (v6)                    ALLOW       Anywhere (v6)             
443 (v6)                   ALLOW       Anywhere (v6)

When I open ip of vps-server in browser I get home page of nginx.


gunicorn

/etc/systemd/system/gunicorn.service

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=root
Group=root
WorkingDirectory=/home/myproject
ExecStart=/home/myproject/myprojectenv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
myproject.wsgi:application
[Install]
WantedBy=multi-user.target

/etc/nginx/sites-enabled# cat /etc/systemd/system/gunicorn.socket

[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target

systemctl status gunicorn - active


Django

/home/myproject/myproject/.settings.py

ALLOWED_HOSTS = ['example.com', 'localhost']

DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.postgresql_psycopg2',
         'NAME': 'test_db',
         'USER': 'test_user',
         'PASSWORD': 'test',
         'HOST': 'localhost',
         'PORT': '',
     }
}

I'm run a manage.py runserver and get response from Django, that the server is started on 127.0.0.1:8000.

But when I open web-site by domain name (f.e., example.com), I get error:

Unable to access site

Failed to find the IP address of the example.com server.

0 Answers
Related