在多租户应用程序中配置NGINX + uWSGI + Django

问题描述 投票:0回答:1

我在AWS上托管的django中有一个应用程序。但是,这些天来,我使用django-tenant-schemas将其变成了多租户。在本地,它正常运行。我可以创建我的租户,并在本地django服务器上访问它们。但是,我不会在AWS上运行。

[的我的[[.conf文件看起来像这样:

upstream django { server unix:///home/ubuntu/folder_my_projct/mysite.sock; # for a file s$ } # configuration of the server server { listen 80; address or $ server_name ssh *.example.com.br; charset utf-8; # max upload size client_max_body_size 75M; # adjust to taste location /media { alias /home/ubuntu/folder_my_projct/media; # your Django project's$ } location /static { alias /home/ubuntu/folder_my_projct/static; # your Django project's$ } # Finally, send all non-media requests to the Django server. location / { uwsgi_pass django; include /home/ubuntu/folder_my_projct/uwsgi_params; # the uwsgi$ } } 我确实为运行在AWS上的项目拉了动,一切都在我的虚拟机中运行(makemigrations和migrate_schemas)。但是,当我尝试访问子域时,它不起作用。我唯一的访问子域的更改是在上面的文件中,在点* .example.com.br之前粘贴
*
。我尝试使用正则表达式,但也无法正常使用(server_name ~^(?<subdomain>.+)\.example\.com\.br $;)。如果有人告诉我我做错了什么,或者我需要做其他事情,我真的很感激。
django amazon-web-services nginx uwsgi multi-tenant
1个回答
0
投票
作者

server_name ssh.example.com.br *.example.com.br;

    server_name *.example.com.br;
  • 对于每个子域,您需要创建配置,具体取决于您要访问的内容
    server { server_name ssh.example.com.br; ... } server { server_name blabla.example.com.br; ... } server { server_name *.example.com.br; ... }
  • © www.soinside.com 2019 - 2024. All rights reserved.