问题描述
如果我想在Google应用引擎(python)上运行我的服务,那么他们都可以轻松创建我自己的自定义子域名吗?
例如,我的服务将运行在我的自定义域上:
www.example.com
对于每位客户,我将创建自己的自定义域名,如:
customer1.example.com
我可能有1000个客户,我们的应用程序将分析子域并查找客户。
这将是一个处理所有子域的单个应用程序。 当然,你的域的通配符(*)CNAME记录(即
然后,将您的第一个webapp2路线之一类似于以下内容:*。example.com
)指向ghs.googlehosted.com
在您的DNS面板中,并且您主域的任何子域的所有请求都将转到您的应用程序(并确保这也反映在
pre>#匹配所有子域但是www
DomainRoute(r'< :(?!www \。)[^。] +> .example.com',[
Route('/ ',handler = CustomSubDomainHandler)
])
这将匹配请求到任何子域, www
one(因为您可能想通过该服务为您的实际应用提供服务)。
和 CustomSubDomainHandler
看起来可能类似于:
class CustomSubDomainHandler(webapp2.RequestHandler):
def get(self):
subdomain = self.request.host.split('。')[0]
#通过分析子域名查找客户的代码在这里.. 。
If I want to run my service on google app engine (python), do they all me to create my own custom subdomains easily and without any limit?
For example, my service will run on my custom domain:
www.example.com
For each customer I will create their own custom domain like:
customer1.example.com
I may have 1000's of customers, so this would have to be easily done using an API call or they allow wildcards.
My application will analyze the subdomain and lookup the customer.
This will be a single application that will handle all subdomains.
Sure, have the wildcard (*) CNAME record of your domain (i.e. *.example.com
) point to ghs.googlehosted.com
in your DNS panel and all requests to any subdomain of your main domain will go to your app (and make sure this is also reflected on the GAE's Custom Domains Settings Page as shown on the screenshot below):
Then have one of your first webapp2 routes as something similar to:
# match all subdomains BUT www
DomainRoute(r'<:(?!www\.)[^.]+>.example.com', [
Route('/', handler=CustomSubDomainHandler)
])
which will match requests to any subdomains but the www
one (since you might want to serve your actual app via that one).
And your CustomSubDomainHandler
could look simmilar to:
class CustomSubDomainHandler(webapp2.RequestHandler):
def get(self):
subdomain = self.request.host.split('.')[0]
# code to look up the customer by analyzing the `subdomain` goes here...
这篇关于GAE是否支持我拥有无限的子域名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!