{"id":62,"date":"2011-10-12T14:51:33","date_gmt":"2011-10-12T18:51:33","guid":{"rendered":"http:\/\/blogs.visigo.com\/chriscoulson\/?p=62"},"modified":"2014-11-05T10:03:19","modified_gmt":"2014-11-05T15:03:19","slug":"mixed-http-and-https-content-with-sharepoint-2010","status":"publish","type":"post","link":"https:\/\/blogs.visigo.com\/chriscoulson\/mixed-http-and-https-content-with-sharepoint-2010\/","title":{"rendered":"Mixed Http and Https Content with SharePoint 2010"},"content":{"rendered":"<p>Have you ever wanted to have mixed https and http content in SharePoint? By that I mean a login page and user pages secured by https, while the rest of the content is delivered unsecured via http. Having the content either all http or all https is a breeze, but I wanted to be able to deliver both, and I ran into problem after problem.\u00a0Here&#8217;s how it&#8217;s done, step by step:<\/p>\n<p><em>Note: This tutorial is going to use the site created in the post <a title=\"Mixed Anonymous and Secure Content with SharePoint 2010\" href=\"https:\/\/blogs.visigo.com\/chriscoulson\/mixed-anonymous-and-secure-content-with-sharepoint-2010\/\">Mixed Anonymous and Secure Content with SharePoint 2010<\/a>. \u00a0If you also want your site to have both anonymous and secured content (and I assume you do!), you may want to read that first.<\/em><\/p>\n<h2>1. Setup Https<\/h2>\n<p>I&#8217;m assuming that you already have your SharePoint web application setup and operating over Http. The first step is to enable it to operate over https as well.<\/p>\n<ul>\n<li>Open IIS and select your SharePoint Web Application from the list of sites.<\/li>\n<li>From the right-hand Actions menu, select &#8216;Bindings&#8230;&#8217;.<\/li>\n<li>From the Site Bindings dialog that opens, click &#8216;Add&#8230;&#8217;<\/li>\n<li>From the Add Site Binding dialog that opens, choose a type of &#8216;https&#8217;. \u00a0This will default to a port of 443. \u00a0You also have to select the SSL Certificate to secure the site with (You have to have already purchased an SSL certificate, or generated a private one). Click OK and close the Site Bindings dialog.<\/li>\n<\/ul>\n<div><a href=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps1orig.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-78\" title=\"httphttps1orig\" src=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps1orig-500x373.png\" alt=\"\" width=\"500\" height=\"373\" srcset=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps1orig-500x373.png 500w, https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps1orig-300x224.png 300w, https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps1orig.png 961w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/div>\n<h2>2. Configure SharePoint to use Https<\/h2>\n<p>In addition to configuring https in IIS, SharePoint also has to be configured to recognize the https address.<\/p>\n<ul>\n<li>Open SharePoint Central Admin and select &#8216;Application Management&#8217;, &#8216;Configure Alternate Access Mappings&#8217;<\/li>\n<li>Select your Web Application from the &#8216;Alternate Access Mapping Collection&#8217;.<\/li>\n<li>Click &#8216;Add Internal URLs&#8217;<\/li>\n<li>Enter the https URL for your site. \u00a0Make sure that the same zone is selected that you access the http version of your site from.<\/li>\n<li>Click OK.<\/li>\n<\/ul>\n<div><a href=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps2orig.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-79\" title=\"httphttps2orig\" src=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps2orig-500x355.png\" alt=\"\" width=\"500\" height=\"355\" srcset=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps2orig-500x355.png 500w, https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps2orig-300x213.png 300w, https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps2orig.png 1110w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/div>\n<div><a href=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps3orig.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-80\" title=\"httphttps3orig\" src=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps3orig-500x355.png\" alt=\"\" width=\"500\" height=\"355\" srcset=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps3orig-500x355.png 500w, https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps3orig-300x213.png 300w, https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps3orig.png 1110w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/div>\n<p>If you try to browse the site, you&#8217;ll notice that you can now browse the site from both the http and the https addresses. There are still a couple of issues though. While browsing the https version of the site, some actions (such as signing out) will bring you back to the http version of your site. \u00a0Also, if you login using https and then browse an http page, you&#8217;ll notice that you&#8217;re no longer logged in. We&#8217;re going to fix these issues in the next couple of steps.<\/p>\n<p><em>Note: If you want ALL of your site content to be delivered via https, and don&#8217;t care about mixed content: instead of adding an internal URL, simply edit the public URLs and change the address to https and YOU&#8217;RE DONE! No need to continue with the rest of this tutorial.<\/em><\/p>\n<p><em>This is also the step that caused me the most grief when initially configuring my SharePoint site for mixed http and https. \u00a0I had initially placed my https URL under the Custom zone of Edit Public URL&#8217;s. Since I only had one actual zone (the default zone, as I hadn&#8217;t extended the web application into multiple zones), the URL in the custom zone would point to it, which I thought would be OK. \u00a0However with this configuration I was always asked to authenticate when switching between http and https. \u00a0The problem was that even though there is only one REAL zone, SharePoint was interpreting the address change as switching between the default and custom zone and was forcing the user to re-authenticate. \u00a0 This is why we add an internal URL for SharePoint to recognize, instead of editing the public URL&#8217;s.<\/em><\/p>\n<h2>3. Configuring SharePoint&#8217;s Authentication Cookie<\/h2>\n<p>Notice that even if you authenticate via https, your authentication isn&#8217;t recognized when you switch over to http. The reason for this is because SharePoint has hard-coded logic that says if it&#8217;s generating an authentication token for an https connection, then turn on the SSL Only flag on the cookie. An SSL Only flag means that the cookie can only be accessed via https. So as soon as you change the address to http, your authentication cookie is no longer recognized and you have to login again.<\/p>\n<p>Tim Nugiel found the solution to this problem. He wrote his own cookie handler that override&#8217;s SharePoint&#8217;s behaviour. See his post for directions on configuring this:<\/p>\n<p><a title=\"Mixing it up w\/ Mixed SSL &amp; SP 2010\" href=\"http:\/\/www.sp2010hosting.com\/Lists\/Posts\/Post.aspx?ID=5\"><del>Mixing it up w\/ Mixed SSL &amp; SP 2010<\/del>\u00a0<\/a>\u00a0<em>(The original link appears to have gone offline)<\/em><\/p>\n<p><a title=\"Mixing it up w\/ Mixed SSL &amp; SP 2010\" href=\"https:\/\/blogs.visigo.com\/chriscoulson\/mixing-it-up-w-mixed-ssl-sp-2010\/\">Mixing it up w\/ Mixed SSL &amp; SP 2010<\/a><\/p>\n<p>You should now be able to authenticate via https, and stay authenticated while browsing content either via http or https &#8211; we&#8217;re almost there!<\/p>\n<h2>4. Redirecting users to Http or Https<\/h2>\n<p>The only issue remaining is forcing certain content to be viewed via http or https. Right now users can access your login page via https, but there&#8217;s nothing forcing them to. \u00a0They could also access it via http. \u00a0The same goes for any other content you want to secure. \u00a0To solve this problem we&#8217;re going to set up some redirect rules using the IIS 7 URL Rewrite module.<\/p>\n<ul>\n<li>Install the IIS7 URL Rewrite module. You can download it from here:\u00a0<a href=\"http:\/\/www.iis.net\/download\/urlrewrite\">http:\/\/www.iis.net\/download\/urlrewrite<\/a><\/li>\n<li>Open IIS and select your SharePoint Web Application from the list of sites.<\/li>\n<li>Open the Url Rewrite module from the Features View.<\/li>\n<\/ul>\n<div>First we&#8217;ll add a rule to redirect secure content to https. For this example our secure pages will be the login page and the pages in our &#8216;User&#8217; site:<\/div>\n<ul>\n<li>Click Add Rules&#8230;<\/li>\n<li>Select &#8216;Blank Rule&#8217; under &#8216;Inbound Rules&#8217; and click OK.<\/li>\n<\/ul>\n<div><a href=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps4orig.png\"><img loading=\"lazy\" decoding=\"async\" title=\"httphttps4orig\" src=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps4orig-500x373.png\" alt=\"\" width=\"500\" height=\"373\" \/><\/a><\/div>\n<ul>\n<li>Fill in the name with &#8216;HTTP to HTTPS Redirect&#8217;.<\/li>\n<li>Set the Pattern to:\u00a0^(_forms\/default.aspx|user\/pages\/.*aspx)<\/li>\n<li>Add the condition: Input: {HTTPS} Check if input string: &#8216;Matches the Pattern&#8217; Pattern: off<\/li>\n<li>Set the Action Type to &#8216;Redirect&#8217;<\/li>\n<li>Set the Redirect Rule to: https:\/\/demo2010a\/{R:0} (Substitute for your own url)<\/li>\n<li>Set the Redirect Type to &#8216;Permanent (301)&#8217;<\/li>\n<li>Click &#8216;Apply&#8217; and click &#8216;Back to Rules&#8217;.<\/li>\n<\/ul>\n<div><a href=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-82\" title=\"httphttps5\" src=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps5-500x425.png\" alt=\"\" width=\"500\" height=\"425\" srcset=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps5-500x425.png 500w, https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps5-300x255.png 300w, https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps5.png 1058w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/div>\n<p>What the rule we created says is:<\/p>\n<p>If the url starts with \/_login\/Default.aspx (The default FBA login page) or \/User\/Pages\/anypage.aspx (any page in the Pages library of our User site) AND if https is not being used THEN send back a Permanent Redirect to the https URL, using the original URL after the server address.<\/p>\n<p>Now we&#8217;ll create a second rule that says all of the pages on the main site should be accessed via http. \u00a0The reason we need this rule is because once we&#8217;re browsing over https, any relative URLs in the page will also be accessed over https. \u00a0So if we want certain pages to be consistently delivered over http, we need a rule to force this:<\/p>\n<ul>\n<li>From the IIS Rewrite module, add another blank inbound rule.<\/li>\n<li>Fill in the name with &#8216;HTTPS to HTTP Redirect&#8217;.<\/li>\n<li>Set the Pattern to:\u00a0^pages\/.*aspx<\/li>\n<li>Add the condition: Input: {HTTPS} Check if input string: &#8216;Matches the Pattern&#8217; Pattern: on<\/li>\n<li>Set the Action Type to &#8216;Redirect&#8217;<\/li>\n<li>Set the Redirect Rule to: http:\/\/demo2010a\/{R:0} (Substitute for your own url)<\/li>\n<li>Set the Redirect Type to &#8216;Permanent (301)&#8217;<\/li>\n<li>Click &#8216;Apply&#8217; and click &#8216;Back to Rules&#8217;.<\/li>\n<\/ul>\n<div><a href=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-83\" title=\"httphttps6\" src=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps6-500x425.png\" alt=\"\" width=\"500\" height=\"425\" srcset=\"https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps6-500x425.png 500w, https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps6-300x255.png 300w, https:\/\/blogs.visigo.com\/chriscoulson\/wp-content\/uploads\/2011\/10\/httphttps6.png 1058w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/div>\n<p>What the rule we created says is:<\/p>\n<p>If the url starts with \/Pages\/anypage.aspx (any page in the pages library of our root site) AND if https is being used THEN send back a Permanent Redirect to the http URL, using the original URL after the server address.<\/p>\n<p>This is just a simple example of what can be done with the IIS Rewrite Module. \u00a0It is very powerful and allows to you to develop very complex rules that can handle almost any redirection you&#8217;d like.<\/p>\n<p><strong>That&#8217;s it! You&#8217;re done! You can now login to your site over https and force content to be read over http or https based on rules.<\/strong><\/p>\n<p>I want to thank <a href=\"http:\/\/www.sp2010hosting.com\">Tim Nugiel<\/a> for taking time out of his busy day to help me troubleshoot issues I was having getting this to work. Tim had the only working example of this that I was able to find on the internet. \u00a0He also developed the SSL Only cookie handler solution. Thanks for all your help Tim!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wanted to have mixed https and http content in SharePoint? By that I mean a login page and user pages secured by https, while the rest of the content is delivered unsecured via http. Having the content either all http or all https is a breeze, but I wanted to be able [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[129,5],"tags":[160,134,133,164,44,168,167,130,137,169,172,156,155,159,161,165,158,157,166,162,173,176,175,177,136,141,22,24,154,153,171,170,163,174],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-configuration","category-sharepoint","tag-alternate-access-mappings","tag-anonymous","tag-authenticate","tag-authenticated","tag-authentication","tag-authentication-cookie","tag-authentication-token","tag-central-admin","tag-content","tag-cookie","tag-cookie-handler","tag-http","tag-https","tag-iis","tag-internal-urls","tag-logged-in","tag-login-page","tag-mixed","tag-mixed-content","tag-public-urls","tag-redirect","tag-redirect-rules","tag-redirection","tag-rule","tag-secure","tag-secured","tag-sharepoint-2","tag-sharepoint-2010","tag-ssl","tag-ssl-certificate","tag-ssl-only","tag-token","tag-url","tag-url-rewrite"],"_links":{"self":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/comments?post=62"}],"version-history":[{"count":2,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":274,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/posts\/62\/revisions\/274"}],"wp:attachment":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/media?parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/categories?post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/tags?post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}