{"id":264,"date":"2008-12-26T05:52:59","date_gmt":"2008-12-25T21:52:59","guid":{"rendered":"http:\/\/www.jhouseconsulting.com\/?p=264"},"modified":"2008-12-26T14:53:58","modified_gmt":"2008-12-26T06:53:58","slug":"http-to-https-redirection-for-citrix-web-interface","status":"publish","type":"post","link":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/2008\/12\/26\/http-to-https-redirection-for-citrix-web-interface-264","title":{"rendered":"HTTP to HTTPS Redirection for Citrix Web Interface"},"content":{"rendered":"<p>I wrote this HTTP to HTTPS redirection script for a customer so that they were able to leave TCP port 80 open through their firewall to make the transition over to using the Citrix Secure Gateway (CSG) solution a little less confusing for their users. There were a couple fo goals I wanted to achieve with this script:<\/p>\n<ol>\n<li>I needed to write a single script that could run from &#8220;C:\\Inetpub\\wwwroot&#8221; and &#8220;C:\\Inetpub\\wwwroot\\Citrix\\XenApp&#8221;.<\/li>\n<li>I didn&#8217;t want to hardcode any customer specific information into the script to make it more universal.<\/li>\n<\/ol>\n<p><!--more-->This script has been fully tested with Citrix Web Interface (WI) 5.0.1 and Citrix Secure Gateway (CSG) 3.1, but can easily be adapted for previous versions.<\/p>\n<p>Please read the comments within the script so that you will understand\u00a0how\u00a0it&#8217;s been\u00a0implemented.<\/p>\n<p>Save this script as default.asp<\/p>\n<pre name=\"code\" class=\"vb.net\">&lt;%@ Language=VBScript %&gt;\r\n&lt;%Option Explicit %&gt;\r\n&lt;%\r\n\r\n' This asp script is used to redirect HTTP to HTTPS, specifically written for Citrix\r\n' Secure Gateway 3.1 and Web Interface 5.0.1.\r\n'\r\n' This allows us to leave port 80 open on the Internet facing firewall so that users\r\n' do not need to remember to type https in the URL address.\r\n'\r\n' Place a copy of this in the root of the Default Web Site, typically C:\\Inetpub\\wwwroot,\r\n' and another copy in the Web Interface Site, typically C:\\Inetpub\\wwwroot\\Citrix\\XenApp.\r\n' Add a default document of default.asp to both sites, and move the default.asp script to\r\n' the top of the list.\r\n'\r\n' If your Web Interface instance is something other than \"XenApp\", you will need to\r\n' change the strWebInterfaceSiteName variable below.\r\n\r\n' Release 1.0 by Jeremy@jhouseconsulting.com on 23rd December 2008.\r\n\r\nDim strWebInterfaceSiteName, strCurrentURL, strNewURL, strHost\r\n\r\nstrWebInterfaceSiteName = \"XenApp\"\r\nstrCurrentURL = Request.ServerVariables(\"URL\")\r\n\r\nIf instr(1,strCurrentURL,strWebInterfaceSiteName,1) &gt; 0 Then\r\n' Perform a case insensitive string comparison to manipulate the URL\r\n\u00a0 strNewURL = replace(strCurrentURL,\"default.asp\",\"default.htm\", 1, -1, 1)\r\nElse\r\n\u00a0 strNewURL = \"\/WebInterface.htm\"\r\nEnd If\r\n\r\n' I found that both \"HTTP_HOST\" and \"SERVER_NAME\" were returning \"localhost\" after\r\n' the redirection, so we use \"HTTP_X_FORWARDED_SERVER\" instead.\r\nIF Request.ServerVariables(\"HTTP_HOST\")=\"localhost\" Then\r\n\u00a0 If Request.ServerVariables(\"SERVER_NAME\") = \"localhost\" Then\r\n\u00a0\u00a0\u00a0 strHost = Request.ServerVariables(\"HTTP_X_FORWARDED_SERVER\")\r\n\u00a0 Else\r\n\u00a0\u00a0\u00a0 strHost = Request.ServerVariables(\"SERVER_NAME\")\r\n\u00a0 End If\r\nElse\r\n\u00a0 strHost = Request.ServerVariables(\"HTTP_HOST\")\r\nEnd If\r\n\r\nIf Request.ServerVariables(\"HTTPS\")\u00a0 = \"off\" Then\r\n\u00a0 Response.Write(\"Redirecting to https:\/\/\" &amp; strHost &amp; strNewURL)\r\n\u00a0 Response.Redirect(\"https:\/\/\" &amp; strHost &amp; strNewURL)\r\nElse\r\n\u00a0 Response.Write(\"Transferring processing over to \" &amp; strNewURL)\r\n\u00a0 Server.Transfer(strNewURL)\r\nEnd If\r\n\r\n%&gt;<\/pre>\n<p>Enjoy!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I wrote this HTTP to HTTPS redirection script for a customer so that they were able to leave TCP port 80 open through their firewall to make the transition over to using the Citrix Secure Gateway (CSG) solution a little less confusing for their users. There were a couple fo goals I wanted to achieve &#8230; <a title=\"HTTP to HTTPS Redirection for Citrix Web Interface\" class=\"read-more\" href=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/2008\/12\/26\/http-to-https-redirection-for-citrix-web-interface-264\" aria-label=\"Read more about HTTP to HTTPS Redirection for Citrix Web Interface\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[122,126],"tags":[128,127],"class_list":["post-264","post","type-post","status-publish","format-standard","hentry","category-citrix-secure-gateway","category-citrix-web-interface","tag-http-to-https","tag-web-interface-redirection"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/comments?post=264"}],"version-history":[{"count":4,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/264\/revisions"}],"predecessor-version":[{"id":266,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/264\/revisions\/266"}],"wp:attachment":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/media?parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/categories?post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/tags?post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}