Avatar of rajithjose
rajithjose asked on

Redirecting http requests to https on Windows 2008

Hi,

I am having a load balanced 2008 CAS servers. I am having multiple email domains like mail.domain1.com, mail.domain2.com etc

1. What I need to do is to redirect http requests to mail.domain1.com, mail.domain2.com etc to https://mail.domain1.com/owa, https://mail.domain2.com/owa
I don't want to edit the error page and redirect all requests to one url, like any requests coming to https://mail.domain1.com/owa
I want to have it redirected to the appropriate urls.

2. I need to add a CNAME record internally for "email" pointing to the load balanced cluster name and when someone types email in browser, it redirects to https://mail.domain1.com/owa

Thanks.
ExchangeWindows Server 2008

Avatar of undefined
Last Comment
LeeDerbyshire

8/22/2022 - Mon
Chris Dent


1.

Use ASP, then you can read the URL used to access the site and redirect accordingly. I have an example of that somewhere, let me dig it out.

2.

DNS cannot redirect you to a sub-folder of a name. That must be done on the Web Server. DNS deals with names, couldn't care les about protocols (HTTP -> HTTPS) or about virtual directories on web servers.

Chris
Chris Dent


Here we go, redirection in ASP based on the URL used to access the site.

Yell if it doesn't work.

Chris
<%
  strURL = Request.ServerVariables("URL")
  If InStr(1, strURL, "mail.domain1.com", VbTextCompare) > 0 Then
    Response.Redirect "https://mail.domain1.com/owa"
  ElseIf InStr(1, strURL, "mail.domain2.com", VbTextCompare) > 0 Then
    Response.Redirect "https://mail.domain2.com/owa"
  End If
%>

Open in new window

ASKER
rajithjose

Should I take off SSL on the default website?
It is a Windows 2008 server, does it need any asp.net components to be loaded?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Chris Dent

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
rajithjose

The code above is not working.

Can we use Case statement, as I have about 10 email domains which needs to be redirected to https://..../owa
Chris Dent


Sure you can use Case. The if set above is just an example.

To test it we should do:

Response.Write Request.ServerVariables("URL")

Then comment out Response.Redirect for now. We just need to make sure of the value we're getting in URL. We might need to use SERVER_NAME instead.

Chris
ASKER
rajithjose

Could you please post a script with case statement just for one case.

ie, redirecting mail.domain1.com to go to https://mail.domain1.com/owa.

I am not at all good with scripts and hence the request.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
rajithjose

Should I turn off SSL while using this script?

When SSL is on, it says 403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
LeeDerbyshire

Sorry - IIS log entries, not IS log entries.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
rajithjose

I am using just mail.domain1.com and it should redirect to https://mail1.domain.com/owa
So, I am not using ssl while accessing the site and hence should I turn off SSL?

ANd I have saved the above script as default.aspx , is that right?
Def doc is pointing to default.aspx as well
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Chris Dent


If the HTTP site is separate from the actual OWA site then HTTPS can be enforced on OWA (as it appears to be at the moment). The HTTP URL would just be available for those that are unable to type https into the browser without becoming confused.

Chris
ASKER
rajithjose

Can I have a CAtch All in the same script?

Like, if it doesn't match any of the cases, it goes to a particular url?
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
rajithjose

I have taken off SSL. It still says 403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
LeeDerbyshire

It will help a lot if you can find your current iis log file, and show us the recorded entries.
ASKER
rajithjose

Following is the error when I type in mail.domain1.com

Server Error in '/' Application.
--------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>
 

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>
 
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.