-2
I have a single application in Django hosted on AWS. But these days, I turned it into multi-tenancy, using Django-tenant-schemas. Locally, it runs normally. I can create my tenants and access them on my local Django server. However, I don’t know how to run on AWS.
My file . conf for NGINX looks like this:
upstream django {
server unix:///home/ubuntu/pasta_meu_projeto/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/pasta_meu_projeto/media; # your Django project's$
}
location /static {
alias /home/ubuntu/pasta_meu_projeto/static; # your Django project's$
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/ubuntu/pasta_meu_projeto/uwsgi_params; # the uwsgi$
}
}
I pulled for my project that runs on AWS, everything worked. And my only change to access the subdomains (only what I changed) was in the file above, pasting the * before the point: *.example.com.br
. I tried to use regex too, but it didn’t work out too well either (server_name ~^(?<subdomain>.+)\.example\.com\.br$;
). Can anyone tell me what I should do? What are the settings of Nginx? If besides tinkering with .conf, I must do some other setting, in some other "place"?
Which wsgi server are you using? what is your question?
– Sidon
Hi, @Sidon! Thanks for replying! I’m using uWSGI. I wonder if there’s something missing in that mine .conf and if I need to do some more configuration, beyond what I’ve already done.
– Thales
Have some special reason for Voce not to use what is almost a standard in the Django world? Gunicorn What problem are you having? Your question is not clear, see that has already been denied.
– Sidon
No, I don’t have any special reason. The two are equivalently good! I just decided to use uWSGI. I’ll try to be clearer...
– Thales
I find it very difficult to say that qq sw is better than others, in that case it would be more difficult even if I didn’t know about uWSGI, but if you asked me for a recommendation I would recommend Gunicorn, for the reason that it is much more widespread in the Django world, see this comparison
– Sidon
When I create the subdomain locally, for example, prefix.localhost, I can access the application: http://prefixo.localhost, on port 8000. I would also like to access prefix.exemplo.com.br on my VPN. Of my initial settings, the only thing I changed was this quoted line (*server_name .example.com.br). When accessing, the created subdomain, does not return me anything, despite realizing that my NGINX is running through that classic message (Welcome to Nginx!), trying to access the domain without prefix, http://exemplo.com.br.
– Thales
Let’s go continue this discussion in chat.
– Sidon
All right, that’s not my question. So please, if you can tell me the steps I should take to turn my single app into a multi, using Gunicorn, I really appreciate it. I believe that the changes of my ngnix settings will not affect my application, even because who is at the door is my NGINX and not who talks to Django.
– Thales
I sent you the link to the solution of multsite in Nginx+gunicorn in chat, try first and, if something goes wrong, rephrase the question or ask another. In time... Your question remains obscure and candidate to close.
– Sidon