0

I have domain mydomain.me in godaddy i set it to point to my ip in aliyun ecs

In my diango settings i have :

ALLOWED_HOSTS = [".mydomain.me","x.x.x.x"] 

in /etc/nginx/sites-avaiable/Django i have

upstream django {
    server unix:/tmp/uwsgi.sock;
}

server {
    listen x.x.x.x:80;
    server_name .mydomain.me;
    location /static/ {
                include uwsgi_params;
                alias /root/DjangoApps/mydomain_me/public;
    }

    location /  {
                include uwsgi_params;
                uwsgi_pass django;

    }
}

**edit : ** for which I made symlink /etc/nginx/sites-enabled/Django, and removed default symlink.

In uwsgi.ini i have

[uwsgi]
chdir = /root/DjangoApps/mydomain_me
module = mydomain_me.wsgi:application
processes = 1
threads = 1
stats = 127.0.0.1:9000
daemonize = /tmp/daemon_app
pidfile = /tmp/uwsgi.pid
chmod-socket = 777
master = True
vaccum = True
socket = /tmp/uwsgi.sock

i run this as follows with pycharm:

ssh://root@x.x.x.x:22/opt/miniconda3/envs/DjangoApps/bin/python3.6 -u /root/DjangoApps/mydomain_me/manage.py runserver 0.0.0.0:8080 
ssh://root@x.x.x.x:22:bash 

root@mydomain:~/DjangoApps/mydomain_me# . activate DjangoApps 
(DjangoApps) root@mydomain:~/DjangoApps/mydomain_me# uwsgi uwsgi.ini 
(DjangoApps) root@mydomain:~/DjangoApps/mydomain_me# service nginx restart 

this is ok:

http://mydomain.me:8080

It worked!

Congratulations on your first Django-powered page.

Next, start your first app by running python manage.py startapp [app_label].

You're seeing this message because you have DEBUG = True in your Django settings file and you haven't configured any URLs. Get to work!

but rhis is not:

http://mydomain.me

with output:

Welcome to nginx!

why its not working?

edit

now mydomain.me gives output:

502 Bad Gateway

nginx/1.10.3 (Ubuntu)

And this are my authorization rules:

outbound:

Allow   
Custom TCP  
8080/8080 and 80/80 and 22/22 and 3389/3389
Address Field Access    
0.0.0.0/0

inbound:

none

Should I change anything? Also my domain point to internet IP address, not elastic one.

edit 1: cat /var/log/nginx/error.log gives me output:

> 2017/08/13 03:00:34 [error] 19132#19132: *11 connect() to
> unix:/tmp/uwsgi.sock failed (111: Connection refused) while connecting
> to upstream, client: x.x.x.x, server: mydomain.me, request:
> "GET /favicon.ico HTTP/1.1", upstream:
> "uwsgi://unix:/tmp/uwsgi.sock:", host: "mydomain.me", referrer:
> "http://mydomain.me/"

And the file /tmp/uwsgi.sock exists, but when:

cat /tmp/uwsgi.sock

it says:

> cat: /tmp/uwsgi.sock: No such device or address
  • 1
    Did you reload nginx after adding the configuration? – Tero Kilkanen Aug 12 '17 at 8:48
  • Always: service nginx restart – yourstruly Aug 12 '17 at 13:30
1

Looks like your Nginx config isn't linked/included. If it's in a directory named sites-available, you'll need to symlink to it from sites-enabled. Edit /etc/nginx/nginx.conf and check which directories it loads config files from.

Example for symlinking a config named default.conf:

cd /etc/nginx/sites-enabled
sudo ln -s ../sites-available/default.conf
sudo service nginx restart
0

So after

cat /tmp/daemon_app

problem was here:

probably another instance of uWSGI is running on the same address (127.0.0.1:9000).

Solution is to kill process using port 9000 and run uwsgi again...

sudo fuser -k 9000/tcp && uwsgi uwsgi.ini

Though, I dont know the reason... Any hints would be nice. I just opened this server yesterday, besides I'm noob in networking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.