Fiexed nginx redirect

This commit is contained in:
Marc Aymerich 2015-03-01 11:56:54 +00:00
parent d601773bf3
commit 4fe7bab605
3 changed files with 38 additions and 18 deletions

17
TODO.md
View File

@ -188,3 +188,20 @@ Multi-tenant WebApps
* username maximum as group user in UNIX
* forms autocomplete="off"
ln -s /proc/self/fd /dev/fd
* http-https/https-only/http-only
POST INSTALL
------------
* Generate a password-less ssh key, and copy it to the servers you want to orchestrate.
ssh-keygen
ssh-copy-id root@<server-address>

View File

@ -50,6 +50,26 @@ class Domain(models.Model):
def subdomains(self):
return Domain.objects.filter(name__regex='\.%s$' % self.name)
def clean(self):
self.name = self.name.lower()
def save(self, *args, **kwargs):
""" create top relation """
update = False
if not self.pk:
top = self.get_top()
if top:
self.top = top
self.account_id = self.account_id or top.account_id
else:
update = True
super(Domain, self).save(*args, **kwargs)
if update:
for domain in self.subdomains.exclude(pk=self.pk):
# queryset.update() is not used because we want to trigger backend to delete ex-topdomains
domain.top = self
domain.save(update_fields=['top'])
def get_description(self):
if self.is_top:
num = self.subdomains.count()
@ -167,23 +187,6 @@ class Domain(models.Model):
value=record.value
)
return result
def save(self, *args, **kwargs):
""" create top relation """
update = False
if not self.pk:
top = self.get_top()
if top:
self.top = top
self.account_id = self.account_id or top.account_id
else:
update = True
super(Domain, self).save(*args, **kwargs)
if update:
for domain in self.subdomains.exclude(pk=self.pk):
# queryset.update() is not used because we want to trigger backend to delete ex-topdomains
domain.top = self
domain.save(update_fields=['top'])
class Record(models.Model):

View File

@ -46,7 +46,7 @@ class Command(BaseCommand):
'server {\n'
' listen 80;\n'
' listen [::]:80 ipv6only=on;\n'
' rewrite ^/$ /admin;\n'
' rewrite ^/$ /admin/;\n'
' client_max_body_size 500m;\n'
' location / {\n'
' uwsgi_pass unix:///var/run/uwsgi/app/%(project_name)s/socket;\n'