R
R
Ruslan Ezhgurov2015-12-01 12:31:14
Django
Ruslan Ezhgurov, 2015-12-01 12:31:14

How to forward subdomains in nginx to a Django project?

Actually, you need to send information about which particular address the user comes to. Subdomains are important so that the backend can get this information. I wanted to do it through a regular expression, but $host is empty in this case (listing all subdomains is nonsense because there are too many of them. I need to come up with something or pull it out, I don’t know

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Maksimov, 2015-12-03
@ValorVl

UWSGI params as an option if you use uwsgi.

S
Salavat Sharapov, 2015-12-05
@desperadik

Try it through the django-hosts
hosts.py application

host_patterns = patterns('',
    host(r'', settings.ROOT_URLCONF, name='www'),
    host(r'(www\.)*(?P<subdomain>[0-9a-z\-]+)', 'base.urls',  callback='base.callbacks.host_subdomains', name='subdomain-area'),
)

callbacks.py
def host_subdomains(request, *args, **kwargs):
   # ищим адрес сабдомена kwargs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question