简体   繁体   English

Nginx和Django在Dotcloud上

[英]Nginx and Django on Dotcloud

I currently have a dotcloud app that uses django to serve everything. 我目前有一个使用django服务一切的dotcloud应用程序。 It works great, however, we recently had our site redone in angular.js, and I don't want to use django to serve the actual html pages (I want to just use nginx for that), but I want django to serve some links for the API we built for the angular code to use. 它工作得很好,但是,我们最近在angular.js中重做了我们的网站,我不想使用django来提供实际的html页面(我想只使用nginx),但我想让django服务一些我们为角度代码构建的API的链接。

Is it possible for me, in the same app, to configure nginx to serve some static files for particular urls, and have it send other urls for django to serve? 我是否可以在同一个应用程序中配置nginx为特定网址提供一些静态文件,并让它为django发送其他网址服务?

I want nginx to serve my index.html page is a request comes in to wwww.example.com, but if a request for example.com/api/login/ comes in, I want that to be handled by django. 我希望nginx能够为我的index.html页面提供服务,请访问wwww.example.com,但如果请求example.com/api/login/,我希望由django处理。 Is this possible? 这可能吗?

Yes, you can do what you are looking for, you just need to add an nginx.conf to your project and then specify which urls you want nginx to serve and which ones you want django to serve, by default they will all go to django, so you just need to specify which ones you want to be served by nginx. 是的,你可以做你想要的,你只需要在你的项目中添加一个nginx.conf,然后指定你想要nginx服务的网址以及你想要django服务的网址,默认情况下它们都会转到django ,所以你只需要指定你想要由nginx服务的那些。

Here is an example for serving static files from nginx, you can use this as a guide to do what you need. 以下是从nginx提供静态文件的示例,您可以将其用作指导,以满足您的需求。

location /media/ { 
      root /home/dotcloud/data ; 
}
location /static/ { 
      root /home/dotcloud/volatile ; 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM