如何使用建议的 Tornado 部署来设置通配符子域名?特别是对于允许用户拥有http://用户名.example.com/以及让他们将自己的域名指向该 URL。
答案1
nginx 只会位于 Tornado 前面,因此假设标准代理配置(Tornado 页面应该列出基本的 nginx 配置)。
通配符配置如下(摘自这里):
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
}
}