如何允许用户将自己的域名用于托管服务?

发布于 2024-07-06 11:06:52 字数 449 浏览 11 评论 0原文

我正在开发一个 ASP.NET MVC Web 应用程序,它允许人们发布内容,但除了将内容发布到远程服务器之外,我希望允许人们直接使用他们的域名。 例如,用户“Tom”可以让他的域名 TomSite.com 指向 http://www。 mywebapp.com/user/tom,但子路径也会被映射。 例如,TomSite.com/path 将映射到 www.mywebapp.com/user/tom/path,这对 Web 访问者是透明的。 访问者永远不会在 TomSite.com 上的任何位置看到“mywebapp.com”。

我认为 Smugmug.com 提供了这样的服务,允许人们使用自己的域名进行照片组合。 我想达到同样的结果。

我怎样才能做到这一点? 谢谢!

I am working on an ASP.NET MVC web app that allows people to publish content, but other than publish the content to a remote server, I want to allow people to use their domain name directly. For example, the user "Tom" can have his domain name TomSite.com point to http://www.mywebapp.com/user/tom, but the sub path will also be mapped. For example, TomSite.com/path will be mapped to www.mywebapp.com/user/tom/path, and this is transparent to the web visitor. The visitor will never see "mywebapp.com" anywhere on TomSite.com.

I think Smugmug.com provides such service, to allow people to use their own domain name for the photo portfolio. I want to achieve the same result.

How can I do this? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

2024-07-13 11:06:53

这需要多个步骤。

首先,您必须了解您的用户将如何配置其域以获得您网站的 CNAME 记录。 您可以通过多种方式实现这一目标,其中最好的是教育。 与托管提供商建立合作伙伴关系需要大量的数量。

在 IIS 中,这将要求您手动添加每个主机名(但这也可以通过脚本来存档)或仅为您的站点提供专用 IP 地址。

还需要将域与帐户关联。 用户必须自己添加此内容,您可能会在界面中添加一个检查,以确认该域指向您的服务器。 其代码如下所示(请记住包含 System.Net 命名空间)。

if (Dns.GetHostEntry("www.user.example.com").HostName == "www.example.com")
{
    // www.user.example.com is a CNAME for www.example.com
}

在 ASP.NET MVC 项目中,您需要为此特定目的实现路由。 创建一个继承自 Route 的自定义类,该类也考虑了域。

This require multiple steps.

First you have to find out how your users will configure their domain to have a CNAME record for you site. You can archieve this in a number of ways where the best is education. Making partnerships with hosting providers requires a great deal of volume.

In IIS this will require you to either add each host name manually (however this could also be archieved through scripting) or have a dedicated IP address only for you site.

There is also a need for the domain to be associated with an account. The user has to add this themselves and you would probably add a check in the interface which confirms the domain is pointed at your server. The code for this would look like (remember to include the System.Net namespace).

if (Dns.GetHostEntry("www.user.example.com").HostName == "www.example.com")
{
    // www.user.example.com is a CNAME for www.example.com
}

In you ASP.NET MVC project you need to implement routes for this particular purpose. Create a custom class inheriting from Route which also takes the domain into account.

Bonjour°[大白 2024-07-13 11:06:53

Smugmug(您提到的那个人)让他们的用户设置一个 CNAME 记录,该记录将为用户的个人照片部分的 url 别名。 对于大多数用户来说,这可能需要他们联系主机或查找帮助文件才能完成所有设置。

因此,虽然 www.tomsite.com 可以透明地提供 www.mywebapp.com 上托管的页面,但用户必须付出一些努力。为了使其完全无缝,您需要与用户网络主机进行某种安排(Smugmug 似乎与 GoDaddy 有这样的安排)。

我怀疑您是否能够与所有网络主机建立这种集成,因此唯一完整的解决方案是自己托管您用户的网站(我对您的更广泛情况了解不够,无法确定这是否合理解决方案)。

注意:在您自己的网络服务器上设置别名(也称为网址重写)将不起作用,除非您自己托管他们的网站,因为显然从您的用户域获取的人们首先不会到达您的服务器。

Smugmug (who you mentioned) get their users to setup a CNAME record that will alias the url for the user's personal photo section. For most users this will probably require them contacting their host or looking up help files in order to get it all setup.

So, while www.tomsite.com could transparently serve up pages hosted at www.mywebapp.com the users will have to put some kind of effort in. To make it a completely seamless you will need some kind of arrangement with the users web host (Smugmug appear to have such an arrangement with GoDaddy).

I doubt you will be able to setup such integration with all the web hosts out there, so the only complete solution would be to host the websites of your users yourself (I do not know enough about your wider situation to determine if that is a reasonable solution).

Note: setting up an alias on your own web server (aka url rewriting) will not work, unless you host their site yourself, as obviously people fetching from your user's domain will not arrive at your server in the first place.

深海夜未眠 2024-07-13 11:06:53

让每个客户的友好名称指向您的网络服务器的外部 IP 地址。

使用 IIS 将主机标头请求中指定的友好名称解析为要传递给该友好名称的逻辑网站。 IIS 很乐意将网站和虚拟文件夹映射到文件系统中的同一文件夹。 为每个客户创建一个网站。 然后将该网站绑定到客户的友好名称。

请记住仅将默认网站映射到您自己的友好名称。 如果将其保留在混杂模式(映射到“*”),结果将是不可预测的。

设置主机标头映射

选择“站点”节点下的“默认网站”。 在右上角的“操作”窗格中,单击“绑定...”以打开“站点绑定”对话框。 将出现一个绑定列表,可能包含一个表示 http * 80 的条目。选择该条目并单击“编辑...”按钮。 将主机名设置为您自己的友好名称。

运行IIS7 Manager并为每个客户站点在站点节点下创建一个网站。 在创建每个网站时设置文件路径和主机标头绑定。 显然,主机标头绑定(主机名)应该是该客户的友好名称。

Have each customer's friendlyname pointed at the external ip address of your webserver.

Use IIS to resolve the friendlyname specified in the host header request to the logical website you want delivered to that friendlyname. IIS will happily map both a website and a virtual folder to the same folder in the file system. Create a website for each customer. Then bind that website to the customer's friendlyname.

Remember to map the default website only to your own friendlyname(s). If you leave it in promiscuous mode (mapped to "*") results will be unpredictable.

To set host header mapping

Select Default Web Site under the Sites node. In the Actions pane at top right click on Bindings... to open the Site Bindings dialog. There will be a list of bindings, probably containing a single entry that says http * 80. Select this and click the Edit... button. Set Host name to your own friendlyname.

Run IIS7 Manager and for each customer site create a website under the Sites node. Set both file path and host header binding while you are creating each web site. Obviously the host header binding (host name) should be that customer's friendlyname.

猫瑾少女 2024-07-13 11:06:53

只需在您的网络服务器中创建一条新记录,将 tomsite.com 直接设置为您的 mywebapp.com/user/tom/ 路径?

像别名一样看待它:)

当然,由于您是基于 asp.net/windows 的,所以我认为您必须深入研究 IIS 才能自动执行此类操作。 如果您使用 apache,则会向 httpd.conf 添加 3 行简单的代码。

Just make a new record in your webserver setting tomsite.com directly to your mywebapp.com/user/tom/ path ?

See it like an alias :)

Ofcourse, since you're asp.net/windows based, i think you'll have to digg deep into IIS to automate this kind of stuff. If you were on apache it would be adding 3 simple lines to httpd.conf.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文