How would someone go about setting up wildcard sub-domains with the suggested Tornado deployment? Specifically for SaaS apps that would allow users to have http://username.example.com/ As well as letting them point their own domain to that URL.
Asked
Active
Viewed 4,649 times
1 Answers
3
nginx would just sit in front of Tornado so assuming the standard proxy config (the Tornado pages should list a basic nginx config).
Wildcard config would be as follows (cribbed from here):
server {
# Replace this port with the right one for your requirements
listen 80;
# Multiple hostnames separated by spaces. Replace these as well.
server_name star.yourdomain.com *.yourdomain.com www.*.yourdomain.com;
root /PATH/TO/yourdomain.com/$host;
error_page 404 http://yourdomain.com/errors/404.html;
access_log logs/access.log;
location / {
root /PATH/TO/yourdomain.com/$host/;
index index.php;
}
# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires 30d;
}
location / {
# insert the various proxy pass directives
}
}

Jauder Ho
- 5,507
- 2
- 19
- 17
-
This works but add root in location block is not good http://wiki.nginx.org/Pitfalls#Root_inside_Location_Block – gagarine Feb 19 '12 at 00:12