1

I'm developing an app with Django 1.8 and I'm trying to receive subdomains and then present customized homepages dependent on the subdomain. For example: example.com is my company's homepage, a user signs up as conqueryor.example.com and they get a new homepage named "conqueryor.example.com" or whatever they want.

Sounds simple enough, there's even the django subdomains library that I'm using. My current issue lies in setting up Apache2 and mod WSGI locally so that I can test it out locally before I affect everyone else on the project. I'm currently able to use the following .conf file with the lines 127.0.0.1 example.dev and 127.0.0.1 .example.dev in my /etc/hosts file. In my browser I'm able to access my app from example.dev, but if I try any subdomains I receive the Server Not Found page. I've also attempted using dnsmasq and adding the line address=/.example.dev/127.0.0.1

Current environment: Ubuntu 15.10 Django 1.8.1 Apache 2.4

<VirtualHost *:80>
ServerName example.dev

DocumentRoot /home/example
ServerAlias www.example.dev

WSGIDaemonProcess example python-path=/home/example:/home/venv/example/lib/python2.7/site-packages
WSGIProcessGroup example
WSGIScriptAlias / /home/example/saas/wsgi.py


<Directory /home/example/static>
Require all granted
</Directory>

<Directory /home/example/saas>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName example.dev


DocumentRoot /home/example
ServerAlias example.dev

WSGIDaemonProcess example2 python-path=/home/example:/home/venv/example/lib/python2.7/site-packages
WSGIProcessGroup example2
WSGIScriptAlias / /home/example/saas/wsgi.py

Alias /static/ /home/example/static/

<Directory /home/example/static>
Require all granted
</Directory>

<Directory /home/example/saas>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName example.dev

DocumentRoot /home/example
ServerAlias *.example.dev

WSGIDaemonProcess example3 python-path=/home/example:/home/venv/example/lib/python2.7/site-packages
WSGIProcessGroup example3
WSGIScriptAlias / /home/example/saas/wsgi.py

Alias /static/ /home/example/static/
<Directory /home/example/static>
Require all granted
</Directory>

<Directory /home/example/saas>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

Thanks!

conqueryor
  • 11
  • 3

1 Answers1

0

I'm going to leave the question in case this helps anyone else, but I found the solution... I forgot I hadn't restarted dnsmasq, so after adding the address=/.example.dev/127.0.0.1 line to /etc/dnsmasq.conf and restarting dnsmasq with sudo /etc/init.d/dnsmasq restart I was able to access sites on subdomains. Oops!

conqueryor
  • 11
  • 3