你将如何使用nginx和龙卷风web服务器设置通配符子域名?

有人会如何设置build议的Tornado部署来设置通配符子域? 特别针对SaaS应用程序,它允许用户拥有http://username.example.com/以及让他们将自己的域名指向该URL。

nginx会坐在Tornado前面,所以假设标准的代理configuration(Tornado页面应该列出一个基本的nginxconfiguration)。

通配符configuration如下(从这里 cri手:脚):

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 } }