Domanda

i'm trying to setup django on nginx + gunicorn on a centos6 server (firewall off, selinux disabled). the project works locally on the server (tested running gunicorn on 127.0.0.1:8221), but not on the whole network. the project should be accessible from a subdomain project.mydomain.com

the project itself is located on a server centos6.mydomain.com and the dns server is main.mydomain.com

my ngnix conf for the project:

upstream project {
    server 127.0.0.1:8221 fail_timeout=0;
}

server {
    listen 80;
    server_name project.mydomain.com;
    access_log /var/log/nginx/project.mydomain.com.log;
    error_log /var/log/nginx/project.mydomain.com.log;

    root /home/USER/djangosites/project;

    location / {
        proxy_set_header Host $host;
        if (!-f $request_filename){
            proxy_pass http://project;
            break;
        }

        }
    location /media  {
        alias /home/USER/djangosites/project/media;
        }
    location /static  {
        alias /home/USER/djangosites/project/static;
    }
}

nginx conf for the centos6 (working)

server {
        listen 80 default_server;
        server_name centos6.mydomain.com;
        access_log /var/log/nginx/centos6.mydomain.com.access.log main;
        error_log /var/log/nginx/centos6.mydomain.com.error.log;

        location / {
                root /var/www/centos6.mydomain.com;
                index index.html;
        }
}

gunicorn conf

import multiprocessing

bind = "127.0.0.1:8221"
logfile = "/home/USER/djangosites/project/gunicorn.log"
workers = multiprocessing.cpu_count() * 2 + 1

would i be better off giving a new ip (to the outside) to the project that is different from centos6.mydomain.com or i can just use the same ip with different local port?

how should i configure hosts.db on main.mydomain.com then?

centos6   A       xxx.xxx.xxx.220
project   A       xxx.xxx.xxx.221

or

centos6   A       xxx.xxx.xxx.220
project   A       xxx.xxx.xxx.220:8221

or

centos6   A       xxx.xxx.xxx.220
project   CNAME   centos6

i'm kind of more inclined to give a new ip because everything is behind a m0n0wall, so a new ip could perhaps be easier to manage.

so basically, i'm guessing that my nginx conf for the project is flawed. what should i do with it?

È stato utile?

Soluzione

ok. got it working :) hosts.db on main.mydomain.com

project   CNAME   centos6

gunicorn runnig on 127.0.0.1:8221 and edited the nginx conf as stated above.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top