我正在开发一个SaaS(软件即服务)的Web应用程序,我正在使用子域名来区分不同的账户。
哪些子域名应该禁止用户使用?
目前我已经有了 admin、administrator、blog、support 和 help。我记得在 Quora 上看到过这样的问题,但现在找不到了。
哪些子域名应该禁止用户使用?
目前我已经有了 admin、administrator、blog、support 和 help。我记得在 Quora 上看到过这样的问题,但现在找不到了。
deny_subdomains :subdomain
(:subdomain是字段),它将阻止/拒绝大量的子域名。这是我用PHP写的版本。我添加了一些自己的内容,也包含了在讨论中提出的建议和dean perry的想法。通过使用一些正则表达式,我能够覆盖许多情况。
/**
* Checks if the subdomain is good. e.g. forbidden names are: ssl, secure, test, tester etc.
* @see https://dev59.com/iWfWa4cB1Zd3GeqPdA3f
* @see https://github.com/deanperry/saas_deny_subdomains/blob/master/lib/saas_deny_subdomains/subdomains.rb
* @return boolean
*/
public function isSubdomainAvailable($subdomain) {
$banned_subdomains_csv = 'admin, login, administrator, blog, dashboard, admindashboard, images?, img, files?, videos?, help, support, cname, test, cache, mystore, biz, investors?
api\d*, js, static, s\d*,ftp, e?mail,webmail, webdisk, ns\d*, register, join, registration, pop\d?, beta\d*, stage, deploy, deployment,staging, testers?, https?, donate, payments, smtp,
ad, admanager, ads, adsense, adwords?, about, abuse, affiliate, affiliates, store, shop, clients?, code, community, forum?, discussions?, order, buy, cpanel, store, payment,
whm, dev, devel, developers?, development, docs?, whois, signup, gettingstarted, home, invoice, invoices, ios, ipad, iphone, logs?, my, status, networks?,
new, newsite, news, partner, partners, partnerpage, popular, wiki, redirect, random, public, resolver, sandbox, search, servers?, service,uploads?, validation,
signin, signup, sitemap, sitenews, sites, sms, sorry, ssl, staging,features, stats?, statistics?, graphs?, surveys?, talk, trac, git, svn, translate, validations, webmaster,
www\d*, feeds?, rss, asset[s\d]*, cp\d*, control panel, online, media, jobs?, secure, demo, i\d*, img\d*, css\d*, js\d*';
$regex = $banned_subdomains_csv;
$regex = preg_replace('#\s#si', '', $regex); // rm new lines, spaces etc
$regex = preg_replace("#,+#si", '|', $regex); // more than one comma
$regex = trim($regex, ','); // remove any leading/trailing commas
$regex = '#^(?:' . $regex . ')$#si'; // let's create a nice regex.
$status = !preg_match($regex, $subdomain); // without main domain added
return $status;
}
Slavi
您可能还想保留自己的名称及其任何变体。
编辑:这只是一个想法,也许有些过头,但您也可以考虑保留类似 i.example.com(“i”代表内部)这样的东西,然后您就拥有了 *.i.example.com 的整个命名空间供内部使用。
app-tenant.domain.com
,其中tenant
是您客户的用户名或公司名称。这意味着您可以在DNS设置中使用类似于app-*.domain.com的通配符来代表您的用户。但如果您使用应用级负载均衡器,这将更加容易。我认为这看起来更漂亮。
注意:据我所知,app.**.domain.com不是有效的。