django nginx gunicorn – 子域名喜悦

我正试图在centos6服务器上设置
django on nginx gunicorn(防火墙关闭,se
linux禁用).该项目在服务器上本地工作(在127.0.0.1:8221上测试运行gunicorn),但不在整个网络上.该项目应该可以从子域project.mydomain.com访问

项目本身位于服务器centos6.mydomain.com上,dns服务器是main.mydomain.com

我的ngnix conf为该项目:

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;
    }
}

nosx conf为centos6(工作)

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

我会更好地给一个新的ip(对外)到与centos6.mydomain.com不同的项目,或者我可以使用相同的ip与不同的本地端口?

我应该如何在main.mydomain.com上配置hosts.db呢?

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

要么

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

要么

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

我更倾向于给出一个新的ip,因为一切都在m0n0wall之后,所以新的ip可能更容易管理.

所以基本上,我猜我的项目的nginx conf是有缺陷的.我该怎么办呢?

最佳答案 好.搞定了:)

main.mydomain.com上的hosts.db

project   CNAME   centos6

gunicorn runnig于127.0.0.1:8221
并编辑了如上所述的nginx conf.

点赞