[英]Uploading django app to digitalocean server: 502 bad gateway nginx/1.4.6 (Ubuntu)
I'm using the following tutorial to upload a django webapp to a digital ocean server. 我正在使用以下教程将django webapp上传到数字海洋服务器。 Everything seems fine while entering the following commands:
输入以下命令时,一切似乎都很好:
pip install --upgrade django
service gunicorn restart
According to the tutorial I now should be able to see my webpage (without the bootstrap theme/fonts) after refreshing the host ip in my browser. 根据该教程,在浏览器中刷新主机ip之后,现在应该可以看到我的网页(没有引导程序主题/字体)。 Instead I get the following error:
相反,我得到以下错误:
I've looked up the nginx error.log in /var/log/nginx/error.log
and it says the following: 我在
/var/log/nginx/error.log
查找了nginx error.log,它显示以下内容:
2017/01/20 08:18:23 [error] 9342#0: *38 recv() failed (104:
Connection reset by peer) while reading response header from
upstream, client: 92.111.75.86, server: _, request: "GET / HTTP/1.1",
upstream: "http://127.0.0.1:9000/", host: "104.236.68.12"
Question: How do I fix this 502 bad gateway so that my site works properly? 问题:如何修复此502错误的网关,以便我的站点正常工作? I've tried to add
ALLOWED_HOSTS = ['104.236.68.12']
to settings.py already and I've also tried to create a droplet with ubuntu 16.04 as well. 我已经尝试将
ALLOWED_HOSTS = ['104.236.68.12']
到settings.py中,并且还尝试使用Ubuntu 16.04创建一个ALLOWED_HOSTS = ['104.236.68.12']
。
You should add the IP address of your DigitalOcean droplet to the ALLOWED_HOSTS variable in your Django settings. 您应该在Django设置中将DigitalOcean Droplet的IP地址添加到ALLOWED_HOSTS变量中。 Starting from your nginx log, I would set:
从您的nginx日志开始,我将设置:
ALLOWED_HOSTS = ['104.236.68.12']
PS: Consider to adopt Docker for the deployment of your django app PS:考虑采用Docker部署django应用
I'm so sorry guys. 真对不起 This solved the issue...
这解决了问题...
Dragging my django app in filezilla to 在Filezilla中将我的Django应用拖到
home/django/django_project
instead of: 代替:
home/django/django_project/django_project
Basically wasn't precise enough when reading the tutorial, so sorry! 基本上在阅读教程时不够精确,很抱歉!
Good day: In the settings.py exactly in ALLOWED_HOSTS = ['*'] 美好的一天:在settings.py中恰好为ALLOWED_HOSTS = ['*']
This will make it collect all the ips. 这将使其收集所有ip。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.