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.
我正在做一个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”。
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.
我认为Smugmug.com提供这样的服务,是为了让人们可以在照片文件夹中使用自己的域名。我想达到同样的结果。
How can I do this? Thanks!
我该怎么做呢?谢谢!
4 个解决方案
#1
2
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.
首先,您必须了解您的用户将如何配置他们的域,以便为您的站点拥有一个CNAME记录。你可以用很多方式记录下来,最好的方式就是教育。与托管提供商建立合作关系需要大量的工作量。
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.
在IIS中,这将要求您要么手动添加每个主机名(不过也可以通过脚本存档),要么只为您的站点提供一个专用的IP地址。
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.
在ASP。NET MVC项目需要为这个特殊目的实现路由。创建一个从Route继承的自定义类,该类还考虑了域。
#2
1
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.
Smugmug(你提到的那个人)让他们的用户设置一个CNAME记录,该记录将为用户个人照片部分的url设置别名。对于大多数用户来说,这可能需要他们联系他们的主机或者查找帮助文件来完成所有的设置。
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).
因此,尽管www.tomsite.com可以透明地提供www.mywebapp.com上的页面,用户将不得不付出一些努力。要使其完全无缝,您需要与用户web主机进行某种安排(Smugmug似乎与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.
注意:在您自己的web服务器(又名url重写)上设置别名将不起作用,除非您自己托管它们的站点,因为显然从用户域获取的用户首先不会到达您的服务器。
#3
1
Have each customer's friendlyname pointed at the external ip address of your webserver.
让每个客户的友好名称指向您的webserver的外部ip地址。
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.
使用IIS将主机头请求中指定的friendlyname解析为要传递到该friendlyname的逻辑网站。IIS将愉快地将网站和虚拟文件夹映射到文件系统中相同的文件夹。为每个客户创建一个网站。然后将该网站绑定到客户的友好姓名。
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.
选择网站节点下的默认网站。在顶部的Actions窗格中,右键单击Bindings…打开站点绑定对话框。将会有一个绑定列表,可能包含一个表示http * 80的条目。选择这个并点击编辑…按钮。将主机名设置为您自己的友好名称。
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.
运行IIS7管理器,为每个客户站点在站点节点下创建一个站点。在创建每个web站点时,设置文件路径和主机头绑定。显然,主机头绑定(主机名)应该是客户的友好名称。
#4
0
Just make a new record in your webserver setting tomsite.com directly to your mywebapp.com/user/tom/ path ?
在webserver设置tomsite.com中直接创建一个新记录到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.
当然,由于您是基于asp.net/windows的,我认为您必须深入到IIS中,以自动化这类东西。如果您在apache上,它将向httpd.conf添加3行简单的代码。
#1
2
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.
首先,您必须了解您的用户将如何配置他们的域,以便为您的站点拥有一个CNAME记录。你可以用很多方式记录下来,最好的方式就是教育。与托管提供商建立合作关系需要大量的工作量。
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.
在IIS中,这将要求您要么手动添加每个主机名(不过也可以通过脚本存档),要么只为您的站点提供一个专用的IP地址。
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.
在ASP。NET MVC项目需要为这个特殊目的实现路由。创建一个从Route继承的自定义类,该类还考虑了域。
#2
1
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.
Smugmug(你提到的那个人)让他们的用户设置一个CNAME记录,该记录将为用户个人照片部分的url设置别名。对于大多数用户来说,这可能需要他们联系他们的主机或者查找帮助文件来完成所有的设置。
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).
因此,尽管www.tomsite.com可以透明地提供www.mywebapp.com上的页面,用户将不得不付出一些努力。要使其完全无缝,您需要与用户web主机进行某种安排(Smugmug似乎与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.
注意:在您自己的web服务器(又名url重写)上设置别名将不起作用,除非您自己托管它们的站点,因为显然从用户域获取的用户首先不会到达您的服务器。
#3
1
Have each customer's friendlyname pointed at the external ip address of your webserver.
让每个客户的友好名称指向您的webserver的外部ip地址。
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.
使用IIS将主机头请求中指定的friendlyname解析为要传递到该friendlyname的逻辑网站。IIS将愉快地将网站和虚拟文件夹映射到文件系统中相同的文件夹。为每个客户创建一个网站。然后将该网站绑定到客户的友好姓名。
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.
选择网站节点下的默认网站。在顶部的Actions窗格中,右键单击Bindings…打开站点绑定对话框。将会有一个绑定列表,可能包含一个表示http * 80的条目。选择这个并点击编辑…按钮。将主机名设置为您自己的友好名称。
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.
运行IIS7管理器,为每个客户站点在站点节点下创建一个站点。在创建每个web站点时,设置文件路径和主机头绑定。显然,主机头绑定(主机名)应该是客户的友好名称。
#4
0
Just make a new record in your webserver setting tomsite.com directly to your mywebapp.com/user/tom/ path ?
在webserver设置tomsite.com中直接创建一个新记录到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.
当然,由于您是基于asp.net/windows的,我认为您必须深入到IIS中,以自动化这类东西。如果您在apache上,它将向httpd.conf添加3行简单的代码。