我在Dotcloud上部署了我的Django应用程序。使用Nginx和自定义服务来提供静态文件。 Dotcloud
我正在使用Gevent和django-socketio的websockets,所以我使用了自定义服务。目前,我仍然使用'runserver_socketio'来使其工作。
现在,我想用Nginx来提供我的静态文件。我发现这个:https://github.com/dotcloud/nginx-on-dotcloud
我试过使用它。这里是我的dotcloud.yml:
www:
type: custom
buildscript: nginx/builder
processes:
app: /home/dotcloud/env/bin/python myproject/manage.py runserver_socketio 0.0.0.0:$PORT_WWW
nginx: nginx
ports:
www: http
systempackages:
- libevent-dev
- python-psycopg2
- libpcre3-dev
db:
type: postgresql
而且我在我的应用程序的根目录下添加了文件夹'nginx'。
我也在安装后的末尾增加:
nginx_config_template="/home/dotcloud/current/nginx/nginx.conf.in"
if [ -e "$nginx_config_template" ]; then
sed > $HOME/nginx/conf/nginx.conf < $nginx_config_template \
-e "s/@[email protected]/${PORT_WWW:-42800}/g"
else
echo "($nginx_config_template) isn't there!!! Make sure it is in the correct location or else nginx won't be setup correctly."
fi
但是,当我去我的应用程序后,我推,我得到的错误:
403 Forbidden, nginx/1.0.14
而且Nginx的不服务错误页面404。
所以我不知道为什么,但我无法再访问我的应用程序。你对我如何使用Nginx设置我的应用程序有任何想法吗?
非常感谢您
你想把你的应用放在nginx的后面,还是放在它的前面? - 如果你把你的应用放在nginx之后,你将无法再使用websockets。 - 如果你把你的应用放在nginx前面,我不确定你会从nginx中获得什么。 所以我想了解背后的理由! – jpetazzo
nginx文件夹位于dotcloud应用程序或django应用程序的根目录下吗? 'nginx:nginx'让我相信nginx进程将在nginx用户下运行。 nginx用户是否有权读取nginx文件夹中的文件? – Enrico
@jpetazzo我不想用nginx来提供我的静态文件,并把我的应用放在nginx前面。我仍然使用runserver_socketio运行我的应用程序,所以我不能将我的DEBUG模式设置为False,因为Django将停止提供我的静态文件。所以我需要使用服务器来做到这一点。我是编程新手,所以我不知道做什么是最好的方法。我会采取任何建议,你可以给我!谢谢您的回答。 – Marcolac