2014-02-10 89 views
0

好吧,我是一个刚刚完成django教程的网站新手,并决定尝试在网上发布我的民意调查应用程序。到目前为止,我有一个godaddy域名,我试图指向我的亚马逊EC2实例的弹性IP,目前正在托管我的民意调查网站。用nginx&gunicorn(godaddy域名/亚马逊ec2实例)Django部署

目前我所成立的是:

亚马逊路线53:指向mydomain.com与记录集的托管区:命名mydomain.com & www.mydomain.com和价值xx.xxx.xx .x

Godaddy:DNS区域文件:我的亚马逊弹性IP xx.xxx.xx.x的A(主机),4亚马逊路由53托管区域名称服务器的名称服务器。

EC2实例:运行nginx和gunicorn来托管应用程序。

我的问题是,我可以去亚马逊的弹性IP的网站,但我不能访问它的域名(我得到一个大胆的“欢迎nginx!”页面,无论我尝试去家里页面或/ polls/1页面。)

回答

0

看起来正确。你是否用nginx跟踪了标准的gunicorn配置?

http://docs.gunicorn.org/en/latest/deploy.html

你可能想在你的nginx CONFIGS是这样的:

http { 
    include mime.types; 
    default_type application/octet-stream; 
    access_log /tmp/nginx.access.log combined; 
    sendfile on; 

    upstream app_server { 
     server unix:/tmp/gunicorn.sock fail_timeout=0; 
     # For a TCP configuration: 
     # server 192.168.0.7:8000 fail_timeout=0; 
    } 

    server { 
     listen 443 default; 
     client_max_body_size 4G; 
     server_name _; 
     ssl     on; 
     ssl_certificate  /usr/local/nginx/conf/cert.pem; 
     ssl_certificate_key /usr/local/nginx/conf/cert.key; 

     keepalive_timeout 5; 

     # path for static files 
     root /path/to/app/current/public; 

     location/{ 
      # checks for static file, if not found proxy to app 
      try_files $uri @proxy_to_app; 
     } 

     location @proxy_to_app { 
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
      proxy_set_header Host $http_host; 
      proxy_redirect off; 

      proxy_pass http://app_server; 
     } 

     error_page 500 502 503 504 /500.html; 
     location = /500.html { 
      root /path/to/app/current/public; 
     } 
    } 
} 

你要指向正确的SSL证书和密钥路径(而不是/usr/local/nginx/conf/cert.pem;/usr/local/nginx/conf/cert.key;)。此外,你应该根指向你的特定的Django静态文件,而不是/path/to/app/current/public

0

好吧,我想通了。

Nginx正在监听127.0.0.1:8000,gunicorn正在播放到127.0.0.1:8001。 (502错误)

要解决DNS问题,我必须进入我的亚马逊EC2控制面板并打开端口8000.