简体   繁体   English

将自定义域映射到通配符子域

[英]Mapping Custom Domains to Wildcard Sub-domains

I'm creating a NextJS project which makes use of wildcard subdomains.我正在创建一个使用通配符子域的 NextJS 项目。

I've set up wildcard subdomains on Vercel, so now each wildcard subdomain points to my main NextJS installation.我已经在 Vercel 上设置了通配符子域,所以现在每个通配符子域都指向我的主要 NextJS 安装。 Within the NextJS app, I'm reading the subdomain name and serving the content accordingly.在 NextJS 应用程序中,我正在读取子域名并相应地提供内容。

So, let's say my wildcard entry is *.example.com所以,假设我的通配符条目是*.example.com

Now, all subdomains, such as roman.example.com , greek.example.com , are being served correctly with content coming from my database correctly.现在,所有子域,例如roman.example.comgreek.example.com ,都可以正确地使用来自我的数据库的内容正确提供。

The challenge I'm facing is to map custom domains to each of these subdomains.我面临的挑战是 map 自定义域到每个子域。

For example, if I want myroman.com to map to roman.example.com and mygreek.com to map to greek.example.com , I'm unable to get it to work. For example, if I want myroman.com to map to roman.example.com and mygreek.com to map to greek.example.com , I'm unable to get it to work.

Say, for example, if in myroman.com DNS records, if I add a CNAME record pointing to roman.example.com , and then if I visit myroman.com , it shows me 404 deployments not found error. Say, for example, if in myroman.com DNS records, if I add a CNAME record pointing to roman.example.com , and then if I visit myroman.com , it shows me 404 deployments not found error. Note that something like myroman.com is a customer's site, and the only thing I can ask a customer is to add a DNS record to map it to a sub-domain.请注意, myroman.com之类的内容是客户的站点,我唯一可以要求客户的是将 DNS 记录添加到 map 到子域。 I cannot take control of their domain or anything like that.我无法控制他们的域或类似的东西。

You would see that companies like substack offer such custom domain mapping to their customers.你会看到像 substack 这样的公司向他们的客户提供这样的自定义域映射。

Can you suggest what's the best way to achieve this?你能建议实现这一目标的最佳方法是什么吗? I'm okay to change host or anything to make this work.我可以改变主机或任何东西来完成这项工作。

Thanks to Krabs, we can host multiple websites inside of our Next.js instance and serve them separately depending on the domain that the user is browsing感谢 Krabs,我们可以在 Next.js 实例中托管多个网站,并根据用户正在浏览的域分别提供它们

https://micheleriva.github.io/krabs/docs/intro/ https://micheleriva.github.io/krabs/docs/intro/

I hope this is what you are looking for!我希望这就是你要找的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM