我想为一个django项目使用多域
一个应用的一个域名
现在我的项目是这样的
test.com/ -> Homepage
test.com/appa -> App A
test.com/appb -> App B
我想换成
^{pr2}$我想我可以用nginx虚拟主机来解决这个问题
但现在我不知道了
请帮帮我。在
现在我用重写它,但不是很好
nginx公司
server {
...
server_name domain2
...
location / {
rewrite / /app1/
...
}
}
当我浏览域2/
它可以重定向到domain2/app1/
但我想要domain2/as/app1/
Nginx可以使用服务器命名空间处理多个域
您可以设置多个服务器(最佳做法为多个文件)和多个上游服务器
^{pr2}$因此每个服务器将被不同的域调用,并将请求传递给不同的uwsgi进程(也称为不同的django app)
Nginx配置的一个示例可能如下所示,请记住,您将需要多个uwsgi进程,每个应用程序一个进程
对于uwsgi解决方案,如果您计划托管多个uwsgi应用程序,请看一下uwsgi emperor。在
它使用一个vassals文件夹,必须将它放在您托管的每个uwsgi应用程序的配置文件中。例如:
/etc/uwsgi/vassals
为了更新应用程序,您不需要停止|启动uwsgi,只需使用以下命令:
touch no-dereference /etc/uwsgi/vassals/any-web-app.ini
附庸配置示例:
它比使用单独的uwsgi命令减少了一般的RAM消耗。线程的工作方式相同,能够为每个应用程序选择多个进程。在
关于nginx,上一篇文章中提到的上游方法工作得很好,而且使用类unix的套接字更快。 关于nginx的nginx上游配置的进一步帮助可以在uwsgi文档的this anchor中找到
最后我用proxy_pass来解决这个问题
通过
^{pr2}$相关问题 更多 >
编程相关推荐