Answer the question
In order to leave comments, you need to log in
Nginx rewrite subdomains + django?
The trouble is, there is a site structure something like this
site.ru/company1/menu
site.ru/company2/menu
site.ru/company3/menu
This is all implemented with a bang on Django
. I want the user to see it as
company1.site.ru/menu
company2 .site.ru/menu
company3.site.ru/menu
But the trouble is how to make it work on subdomains. use batteries from django for example django-hosts
or rewrites on nginx can solve this case?
about django-hosts, it turns out that I can easily put an application on a subdomain, and my applications will be in all subdomains, for example, the news application will be for all company*
how to be?
Answer the question
In order to leave comments, you need to log in
The nginx config will look something like this:
server {
server_name ~^(?<company>.+)\.site\.ru$;
location / {
try_files /path/to/static/media @django;
}
location @django {
fastcgi_pass unix:/tmp/site.django.socket;
fastcgi_param PATH_INFO /$company$uri;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param REMOTE_ADDR $remote_addr;
}
}
/company1/menu/item
, it will have to create a link /menu/item
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question