0

if I do systemctl start nginx, it just goes to the next empty line, without letting server to work, like so:

[[/home/sc/pro]]# systemctl start nginx
[[/home/sc/pro]]#

if I do nginx -t:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

if I do netstat -ntlp, I see following:

N      1684/nginx: master
tcp6       0      0 :::465                  :::*                    LISTE

in /etc/nginx/nginx.conf:

server{
        listen 80;
        #listen [::]:80 ipv6only=on; <- I tried it too
        server_name "my_ip_address";

        location = /favicon.ico {access_log off; log_not_found off;}
        location /static/ {
                root /home/sc/pro/projects/sc/sc_site;
        }

        location / {
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_pass http://unix:/home/sc/pro/sc_project/sc_project.sock;
        }
    }

Moreover, if I do following command, system tells me following :

(sc_project) [ [/home/sc/pro/projects/sc]]# gunicorn --bind 0.0.0.0:8000 sc.wsgi:application
[2020-09-08 14:05:16 +0000] [4209] [INFO] Starting gunicorn 20.0.4
[2020-09-08 14:05:16 +0000] [4209] [INFO] Listening at: http://0.0.0.0:8000 (4209)
[2020-09-08 14:05:16 +0000] [4209] [INFO] Using worker: sync
[2020-09-08 14:05:16 +0000] [4211] [INFO] Booting worker with pid: 4211

But i cannot get to my site anyway... Although earlier when I just installed gunicorn and did this command i was able to get to the site...

I killed httpd process with the following command:

sudo kill -2 <PID>

... which was taking port 80... I tried to use apache earlier and it didn't work for me... Now I'm not sure if it was httpd or http process, and whether I need it or not... But by journalctl -x it was not allowing gunicorn to use port 80...

Also i'm not sure if I did restrictions right: I'm root for my site...I used these commands for sc, which is root folder for my project (as: /home/sc) and supposed to be a user's name which holds all projects down the tree: usermod -a -G sc nginx chmod 710 /home/sc

I was following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-centos-7

1 Answers1

0

You have configured nginx to try to connect to gunicorn via a UNIX socket, but you configured gunicorn to listen on TCP port 8080. Therefore they cannot communicate. You must change one or the other configuration so that they match.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • I'm trying to understand. Should I do server{listen 8000}? – user590950 Sep 08 '20 at 14:52
  • @user590950 No, and I didn't say anything about that. – Michael Hampton Sep 08 '20 at 14:55
  • Sorry, I'm a total noob at the servers... Just trying to set the server for a couple of days:( – user590950 Sep 08 '20 at 14:56
  • Sorry, due to my noobiness in this question I understand what to do... but have no idea how to do it. I just look at the default settings for nginx.conf. At this address: https://docs.gunicorn.org/en/stable/deploy.html... They advise to do the following: listen 80 default_server; return 444; – user590950 Sep 08 '20 at 15:32