« Previous Next »

Thread: Host Header Configuration with Default Website and Sharepoint Services on the Same Machine

Last post 11-15-2007 4:39 AM by dvugteveen. 6 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (7 items)

Sort Posts:

  • 10-16-2007, 2:05 PM

    • PetrTab
    • Not Ranked
    • Joined on 10-04-2007, 10:48 PM
    • Posts 3

    Host Header Configuration with Default Website and Sharepoint Services on the Same Machine

    Hi All,

    I'm attempting to connect over the internet to one of serveral websites on a single IP Address using Host Headers. The problem is that I'm coming into the server with an IP Address instead of a registered domain name. So I'm attempting name resolution after arriving at the server and not prior as is normally done. I'm trying to setup http://xxx.xxx.xxx.xxx/<host header> like sharepoint does for http://xxx.xxx.xxx.xxx/remote and http://xxx.xxx.xxx.xxx/clientaccess. I can not find information on this type of configuration.

    I have a Small Business Server 2003 domain controller running Routing and Remote Access behind a Linksys router. The default website  and Windows Sharepoint Services (including remote, clientinfo, companyweb, etc) are intalled and work as expected. I am able to to use the "Configure E-mail and Internet Connection Wizard" (or manual settings) to expose the default website to external requests.

    I would like to setup a second website independent of the default website and sharepoint. I would prefer to keep all http access on default port 80 relying on Host Headers for website name resoution.

    Using IIS 6.0, I've created a new website named "Test" in its own directory c:\Test including a default page and a web.config file. I set the host header to "Test", set the IP to the server and left default port 80. I also added an alias/cname for "Test" in the server DNS. Locally, I am able to go to http://Test just as it is possible to go to http://companyweb. But I would also like to connect from the internet using http://xxx.xxx.xxx.xxx/Test and this is where I'm having the problem.

    If I can't get this configuration to work, I'll go on to a non-standard port configuration, but I would prefer a host header solution.

    Note: I noticed that if I configure "Test" with a blank Host Header, on port 80 and change "All Unassigned" to point to the server IP, then internet requests to the WAN IP will go to my new website "Test" default page. But doing this disables access to the default website and sharepoint as would be expected. I mention this to show that internet traffic can pass through the router/firewall configuration.

    Any help/thoughts with this configuration would be greatly appreciated.

  • 10-16-2007, 3:00 PM In reply to

    Re: Host Header Configuration with Default Website and Sharepoint Services on the Same Machine

    You can't do this with host headers.  You can use the IP as a host header, but not the directory name.  If all your pages fall under that same IP address, you could segregate this with a host header to the IP and each subdirectory part of the same site.  You could also use ASP.NET's URL Rewrite or ISAPIRewrite to redirect to the location you desire based on a directory name.  Essentially, for both http://192.168.1.1/folder1 and http://192.168.1.1/folder12, you have the same host with different subdirectories.

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 10-17-2007, 8:13 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Central NJ
    • Posts 6,166
    • IIS MVPs

    Re: Host Header Configuration with Default Website and Sharepoint Services on the Same Machine

    It sounds like you're misunderstanding what a host header is - it represents a server name, not a directory name, so it gets used in place of the IP address.

  • 10-17-2007, 4:55 PM In reply to

    • PetrTab
    • Not Ranked
    • Joined on 10-04-2007, 10:48 PM
    • Posts 3

    Re: Host Header Configuration with Default Website and Sharepoint Services on the Same Machine

    I didn't mean to imply that I want to use host headers to resovle directories. I just happened to have named all three (the directory, the website, and the Host Header as "Test". I created a host header named "Test" for a website named "Test" in a directory named "Test". I also needed to create an entry in my server DNS to resolve the name "Test" so that it would be accessible on the local network by http://Test. This works and confirms that my host header is setup correctly for local access - intranet type connections.

    Normally for internet access, I would setup a subdomain "Test.mydomain.com" and register this subdomain with a registrar. Then I would setup the host header to be "Test.mydomain.com". IIS would then be able to resolve requests to Test.mydomain.com and send these requests to my website named "Test". However, in my scenario, I only have a ip address with no plans for a domain name, and I was curious to know if there may be some way to format the url to indicate a specific host header.

    I noticed that for some areas of sharepoint, you can use http://xxx.xxx.xxx.xxx/Remote or http://xxx.xxx.xxx.xxx/ClientHelp and these urls do get resolved correctly when accessed from the internet. This leads me to believe that I can configure something similar for the website that I create.

    I've even tried duplicating the "Remote" folder within the sharepoint web directory and renaming it to "Test" to try http://xxx.xxx.xxx.xxx/Test and this does not work. So I'm seeing an implementation of what I want, but I don't know how to configure it.

    In the previous post, Jeff brought up the Url Rewrite method, which I've been investigating as a possibility. I see that the Rewrite method can be implemented at the ISAPI Filter level or the ASP.net level. At the ASP.net level, you can use http modules or http handlers to respond to anyone of the many events. Then depeding on whether authorization or authentication is used, if any, the Rewrite method is subject to fail depending on the choices of implementation. And then I still don't know if the Url Rewrite method would give me access the to intranet host header "Test" that I've setup.

     

     

     

  • 10-18-2007, 8:53 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Central NJ
    • Posts 6,166
    • IIS MVPs

    Re: Host Header Configuration with Default Website and Sharepoint Services on the Same Machine

    PetrTab:
    However, in my scenario, I only have a ip address with no plans for a domain name, and I was curious to know if there may be some way to format the url to indicate a specific host header.
    No - In that case, you can not use host headers as they require DNS.

    PetrTab:
    I noticed that for some areas of sharepoint, you can use http://xxx.xxx.xxx.xxx/Remote or http://xxx.xxx.xxx.xxx/ClientHelp and these urls do get resolved correctly when accessed from the internet. This leads me to believe that I can configure something similar for the website that I create.

    I've even tried duplicating the "Remote" folder within the sharepoint web directory and renaming it to "Test" to try http://xxx.xxx.xxx.xxx/Test and this does not work. So I'm seeing an implementation of what I want, but I don't know how to configure it.

    If the root of your server (http://xxx.xxx.xxx.xxx/) is hosting SharePoint, and you want to have a /Test folder that is outside of SharePoint, you need to tell SharePoint to ignore/exclude that folder.  In WSS 2 there's a way to do this, I'm trying to find out how it's done with WSS 3 ...

  • 10-26-2007, 8:40 PM In reply to

    • PetrTab
    • Not Ranked
    • Joined on 10-04-2007, 10:48 PM
    • Posts 3

    Re: Host Header Configuration with Default Website and Sharepoint Services on the Same Machine

    I was looking at the IIS metabase which stores the host header as xxx.xxx.xxx.xxx:<port>:<host header> and it seemed that you may be able to specify the host header in the URL with a colon after the port, but that's not the case as Tomkmvp points out. The host header is stored in the application layer, while the IP and Port are stored in the TCP/IP transport layer. So in the case of an IP address using a default port 80, it appears that IIS sends all requests to the default website (sharepoint services website in my case). The alternative being that you have a registered domain name for each site hosted on your IIS, and in that case, IIS is able to resolve these domain names as host headers on the same IP and Port.

    I've been working with the URL Rewrite/Redirection concept offered by Jeff. There is the ASP.net level URL Rewrite and the ISAPI Filter level URL Rewrite. To use ASP.net URL Rewrite, the request must be for a page with an asp extension (*.asp, *.aspx, etc.) so that IIS knows to hand off the request to ASP.net where the rewrite code can be executed. That's too far down the IIS pipeline where my goal is an extensionless URL Rewrite (http://xxx.xxx.xxx.xxx/Test). To create an extensionless URL Rewrite, you have to move up the IIS pipeline to the ISAPI Filter level. This required that I create a IIS Filter as a DLL file, and I found a good article at The Code Project http://www.codeproject.com/isapi/isapiredirector.asp that shows how to implement this.

    I was able to modify, compile and run The Code Project sample ISAPI Filter code successfully to perform URL Rewrites within the default website. Ultimately, I was hoping that I would be able to redirect to the intranet host headers like http://Test, but that did not work. I know that my host headers on the intranet do work. Either IIS cannot make that connection (between a path and a host header), or my function code is incorrect for this. To illustrate, below is an example of one of my failed attempts:

    DWORD CredirectorFilter::OnPreprocHeaders(CHttpFilterContext* pCtxt,
     PHTTP_FILTER_PREPROC_HEADERS pHeaderInfo)
    {
     // TODO: React to this notification accordingly and
     char buffer[256];
        DWORD buffSize = sizeof(buffer);
        BOOL  bHeader=pHeaderInfo->GetHeader(pCtxt->m_pFC, "url", buffer, &buffSize);
     
     CString urlString(buffer);
        urlString.MakeLower(); // for this exercise
        if (urlString.Find("Test") != -1) //we want to redirect this file
        {
      urlString.Replace(http://xxx.xxx.xxx.xxx/Test, http://Test);
            char *newUrlString= urlString.GetBuffer(urlString.GetLength());
            pHeaderInfo->SetHeader(pCtxt->m_pFC, "url", newUrlString);
            return SF_STATUS_REQ_HANDLED_NOTIFICATION;
        }

     // return the appropriate status code
     return SF_STATUS_REQ_NEXT_NOTIFICATION;
    }

    I've done a lot of testing and found that the code above returns header informatiion that appears to be relative within the default website. For example, I am able to replace "\default.cfm" with "\default.htm" or  \default.cfm" with "\Test\default.htm" successfully. But I am having trouble redirecting to something like http://www.microsoft.com.

    Again, my overall question is how to come into IIS on an IP address and Port 80, and direct the request to a specific website on IIS in a way that Sharepoint remains intact on the default website.

    My current thinking is that an ISAPI Filter may be an option. Any help with the ISAPI Filters would be greatly appreciated.

     

  • 11-15-2007, 4:39 AM In reply to

    Re: Host Header Configuration with Default Website and Sharepoint Services on the Same Machine

    Check out http://blogs.msdn.com/joelo/archive/2007/01/02/relationship-between-the-iis-metabase-and-sharepoint-configuration-database.aspx 

    Key section: "You can use IP bindings but they aren't exposed in the SharePoint web application creation UI, first go into SharePoint to extend the web application with a host header binding, then go into IIS Manager to remove the host header binding and add an IP binding and SSL certificate to the IIS Web site as applicable. Be sure to do an IIS metabase backup, restart the WSS Web Application Service and then restore the IIS metabase."

Page 1 of 1 (7 items)
Microsoft Communities