Apache:将动态子域重定向到不同的 IP
我有一个带有动态子域的应用程序,应该根据子域的一部分重定向到不同的服务器。
示例(任何内容都意味着您想要的任何内容,动态名称):
example.com --> server1
anything.example.com --> server1
a.example.com --> server2
b.example.com --> server1
a.anything.example.com --> server2
b.anything.example.com --> server1
anything.a.example.com --> server2
anything.b.example.com --> server1
a.anything.a.example.com --> server2
b.anything.a.example.com --> server2
我想这不可能使用标准 dns 配置来实现。 因此,我计划将 *.example.com 指向 server1,并配置 apache 在符合任何条件时将请求转发到 server2。 问题是我不知道如何为此配置 apache。 有人知道从哪里开始吗?
I have a application with dynamic subdomains that should be redirected to different servers depending on a part of the subdomain.
Example (anything means whateveryouwant, a dynamic name):
example.com --> server1
anything.example.com --> server1
a.example.com --> server2
b.example.com --> server1
a.anything.example.com --> server2
b.anything.example.com --> server1
anything.a.example.com --> server2
anything.b.example.com --> server1
a.anything.a.example.com --> server2
b.anything.a.example.com --> server2
I guess this is not possible to do with standard dns configuration. So instead I'm planning to point *.example.com to server1 and the configure apache to forward the request to server2 when it matches any of the criterias. Problem is that I don't know how to config apache for this. Does anyone have an idea of where to start?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我所说的“任何东西”是指动态名称,例如应用程序用户的用户名。 所以我不能为其中每一个都创建一个 DNS 记录,它可能有数百万条。
With "anything" i meant a dynamic name, like the usernames of the users of the application. So I can not make a dns record for each one of these, it could be millions.
当然可以在 DNS 中完成。 只需为
example.com.
、anything.example.com.
、b.example.com.
等创建 A 记录,这些记录都具有服务器 1 的 IP,对于服务器 2 上您想要的域也类似。当然,您仍然需要为每台服务器上的各个域配置虚拟主机,但您不需要从一台服务器进行任何重定向到另一个。Sure you can do it in DNS. Just create A records for
example.com.
,anything.example.com.
,b.example.com.
, etc. that all have the IP of server 1, and similarly for the domains you want on server 2. Of course, you'll still have to configure virtual hosts for the various domains on each server, but you won't need to do any redirecting from one server to the other.