首页 > 解决方案 > django应用的AWS部署

问题描述

我有一个部署在 aws 中的 django 应用程序。ec2 实例中的 URL 也可以正常加载。我的应用程序有一个模式,我应该在其中输入我的团队名称和用户名。每当我尝试[ec2instanceurl]:8000/(当我启动 gunicorn 时)时,我都没有遇到任何警报错误。

但是,当我启动 nginx 并访问没有端口(8000)的 url 时,页面正在加载,每当我在模式中输入详细信息并单击确认按钮时,它都会显示一条警报“[ec2instanceurl] 说错误”

我将在此处附上错误快照

我想知道这是我的 django 应用程序错误还是任何 aws 设置错误。问题是它在当地和gunicorn港口工作得很好。在此处输入图像描述

虽然我是 aws 部署的新手,但我期待建议.. 在此先感谢

nginx 配置文件(/etc/nginx/sites-available)

server {
  listen 80;
  server_name ec2-34-232-78-132.compute-1.amazonaws.com;

  location / {
     include proxy_params;
      proxy_pass http://unix:/home/ubuntu/rest_project/app.sock;
    }
}

gunicorn 配置文件

[program:gunicorn]
directory=/home/ubuntu/rest_project
command=/home/ubuntu/env/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/rest_project/app.sock rest_project.wsgi:application
autostart=true
autorestart=true
stderr_logfile=/var/log/gunicorn/gunicorn.err.log
stdout_logfile=/var/log/gunicorn/gunicorn.out.log

[group:guni]
programs:gunicorn

nginx的日志(错误日志) 在此处输入图像描述 访问日志 在此处输入图像描述

gunicorn command:

gunicorn --bind 0.0.0.0:8000 rest_project.wsgi:application

标签: djangoamazon-web-services

解决方案


推荐阅读