Infinite Redirect Loop When Going From non-SSL to SSL

Hi,

I’m trying to get things up and running in a cloud environment.

when I click on pages(ASP.NET) that use HTTPS protocol, page hangs. I think it is really doing the loop due to re-direction from HTTP to HTTPS.

Any ideas on how to fix this?

I tried asking tech support environment and they told me to use SSL throught my site or don’t use it.

Please help!!

thanks,

regards,

CK

=========== Answer 1 ===========

.IsSecureConnection doesn’t work. You have to use an environment variable to check for SSL

https://manage.rackspacecloud.com/forum/posts/list/1464.page

=========== Answer 2 ===========

correct! I had the following code:

if (!Request.IsSecureConnection)
{
// send user to SSL
string serverName =HttpUtility.UrlEncode(Request.ServerVariables[“SERVER_NAME”]);
string filePath = Request.FilePath;
Response.Redirect(“https://” + serverName + filePath);
}

and it hangs. what is the equivalent code that I should use for cluster environment? Thanks,

CK

=========== Answer 3 ===========

if(Request.ServerVariables[“HTTP_CLUSTER_HTTPS”] != “on”) { // we need to redirect
// check to see if the other Server Var is defined, if not redirect otherwise dont

if(Request.ServerVariables.Get(“HTTP_CLUSTER-HTTPS”) == null) {
Response.Redirect(“https://” + Request.ServerVariables[“HTTP_HOST”] + newUrl);
}
}

Here is another one:

<system.webServer>
<rewrite>
<rules>

<rule name=”Redirect to HTTPS” stopProcessing=”true”>
<match url=”(.*)” />
<conditions>
<add input=”{HTTP_CLUSTER_HTTPS}” pattern=”^OFF$” />
</conditions>
<action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}” redirectType=”SeeOther” />
</rule>

</rules>
</rewrite>
</system.webServer>

=========== Answer 4 ===========

Yep, I linked too fast. I linked to a thread on getting the IP address for SSL, which is related, but different.

You may want to take note of it though, because you may at some point want to get the IP address of your visitors, and ServerVariables(“REMOTE_ADDR”) won’t work, you’ll need the HTTP_X_FORWARDED_FOR variable if you are on SSL.

=========== Answer 5 ===========

Hi,

I am using URLRewriter an open source module. Following is the script I use

<rewriter>
<if header=”HTTP_HOST” match=”^www.MyDomain\.com$”>
<redirect url=”^(.+)$” to=”http://MyDomain.com$1″/>
</if>
<!–<if header=”HTTP_CLUSTER_HTTPS” match=”^OFF$”>
<redirect url=”^~/test.aspx$” to=”https://MyDomain.com/test.aspx”/>
</if>–>
</rewriter>

I tested this last night and the page still hangs.

regards,

Chandar

Rackspace Secrets

Leave a Reply

Your email address will not be published. Required fields are marked *