Setting up your App domain for SharePoint 2013

一隻老鼠發表於2013-07-10

from:http://sharepointchick.com/archive/2012/07/29/setting-up-your-app-domain-for-sharepoint-2013.aspx

The most important change in SharePoint 2013 for developers is the introduction of SharePoint apps. An app for SharePoint is a small and isolated application that provides a specific bit of functionality. SharePoint apps can and have to be added to or removed from a site by the site owner.  Apps have their own, isolated URLs, which are separate from the URLs of the sites where the app is being deployed to and where the app is being used. In order to provide isolation apps run in their own domain, instead of in the same domain name as your farm. Using a different domain name for apps helps prevent cross-site scripting between apps and SharePoint sites.
Each installation of an app has its own unique URL within the app domain. The app’s URL is based on a template “http://[app prefix][app hash].[app domain]/[relative site url]/[app name]. When you add an app to a site, a subweb of that site is created to host the app content. This subweb is not visible on the Site Contents page though.

Because apps run in their own app domain you will have to configure Domain Name Services (DNS) in your environment in order to be able to host apps. There is a page on TechNet that describes how to setup you DNS, but because it took me a while to get it all working I decided to write a step by step guide, which is what you’re reading now.

You can choose whether you want your app domain to be a subdomain of the domain that hosts the SharePoint environment (option B), or whether you want to create a completely new domain for your apps (option A). Creating a new domain specifically to host your apps in is a bit more secure, but it also requires a little bit more configuration. I will describe both approaches in this article. If you don’t have control over your DNS you will have to ask an administrator to perform these steps for you.

Option A: Create a new domain to host your apps in

  • Go to “Start”
  • Click on “Administrative Tools”
  • Select “DNS”

Open DNS

  • Right click “Forward Lookup Zones” and select “New Zone…”
  • Click “Next”
  • Keep the default and click “Next” again
  • In most cases, especially if your development server is in it’s own domain you can use the default on the next tab again and can just click “Next”
  • You now have to specify a zone name. It’s up to you what you choose here. My domain name is “solutions.com” and for my app domain I will use “solutionapps.com”
  • Click “Next”

New Zone Wizard

  • Click “Next”
  • Click “Finish”

DNS Manager

  • Right click on your new zone and select “New Alias (CNAME)…”
  • Fill in a * for “Alias name (uses parent domain if left blank)”
  • Click “Browse”
  • Double click on your server name
  • Double click “Forward Lookup Zones”
  • Double click the domain of your SharePoint environment. In my case this is “solutions.com”.
  • Select “(Same as parent folder)” and click “OK”
  • Click “OK”.

* Note that selecting the FQDN of the domain in here will only work in single server scenarios. If you are using more than one server you should be pointing to the DNS record of the web server in here. This is either the DNS A record for the web server, or the DNS record of the primary cluster address for NLB environments.

Create a CNAME

  • You are now done setting up your DNS and it should look like this:

DNS Manager

Option B: Create a subdomain to host your apps in

  • Go to “Start”
  • Click on “Administrative Tools”
  • Select “DNS”

Open DNS

DNS Manager

  • Right click on the name of your domain and select “New Alias (CNAME)…”
  • Fill in “*.app” for “Alias name (uses parent domain if left blank)”
  • Click “Browse”
  • Double click on your server name
  • Double click “Forward Lookup Zones”
  • Double click the domain of your SharePoint environment. In my case this is “solutions.com”
  • Select “(Same as parent folder)” and click “OK”
  • Click “OK”

* Note that selecting the FQDN of the domain in here will only work in single server scenarios. If you are using more than one server you should be pointing to the DNS record of the web server in here. This is either the DNS A record for the web server, or the DNS record of the primary cluster address for NLB environments.

Create a new CNAME

  • You are now done setting up your DNS and it should look like this:

DNS Manager

Configuring SharePoint

I’m assuming you already created an App Management and a Subscription Settings Service Application and that you already started the App Management and Subscription Settings services on your servers. If not this MSDN article will tell you how to. Note that you have to use PowerShell to create the Subscription Settings Service Application. There is no user interface for it.

Service Applications

Services on Server

  • Go to Central Administration
  • Click on “Apps” in the left side navigation
  • Click “Configure App URLs”
  • Fill in the URL of the app domain that you configured. If you choose to use Option A the url will be something like “solutionapps.com”, if you choose to use Option B it will look like app.solutions.com.
  • Fill in an app prefix. This can be anything you like, although it is best to keep this short. I used “app” myself.

Configure App URLs

Two example urls for two different apps on the same site are:
http://app-fef8493a3feb20.solutionapps.com/sites/apptest/[App1AppName]/Pages/Home.aspx
http://app-fef8493a3feb1d.solutionapps.com/sites/apptest/[App2AppName]/Pages/Default.aspx
As you can see both apps have their own app hash, but both are in the same domain.

Beware of host headers

You are now ready to deploy your apps. Because of all this extra domain stuff though there are a few things you should know about your web applications and site collections.
If you are using a host header for your web application apps won’t just work for that web application. Because of how the redirect for the app domain works IIS will try to resolve the app url by using the default IIS web site, which of course doesn’t work. If you want to use host headers for your web applications you have to create an extra web application that is listening on port 80 (or 443 if you are using https) and that doesn’t have a host header.
This means that you have to create a web application like you normally would. You have to make sure that you select port 80 (or 443 if you are using https) and you should not fill in a host header. Note that you have to stop the Default Web Site in IIS in order to be able to do this. The web application will use the server name as its url. The web application can be empty except for a root site collection.

Another option is to use web applications without host headers and to create Host Header Site Collections. Be aware that Host Header Site Collections cannot be created via the user interface, they can only be created by using PowerShell.

相關文章