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
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image


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
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image


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

Avatar of rajithjose
rajithjose

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of rajithjose
rajithjose

ASKER

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
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image


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
Avatar of rajithjose
rajithjose

ASKER

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.
SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of LeeDerbyshire
LeeDerbyshire
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of rajithjose
rajithjose

ASKER

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
Avatar of LeeDerbyshire
LeeDerbyshire
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of LeeDerbyshire
LeeDerbyshire
Flag of United Kingdom of Great Britain and Northern Ireland image

Sorry - IIS log entries, not IS log entries.
SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of rajithjose
rajithjose

ASKER

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
SOLUTION
Avatar of LeeDerbyshire
LeeDerbyshire
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image


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
Avatar of rajithjose
rajithjose

ASKER

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
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of rajithjose
rajithjose

ASKER

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.
Avatar of LeeDerbyshire
LeeDerbyshire
Flag of United Kingdom of Great Britain and Northern Ireland image

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

ASKER

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
Avatar of LeeDerbyshire
LeeDerbyshire
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Exchange
Exchange

Exchange is the server side of a collaborative application product that is part of the Microsoft Server infrastructure. Exchange's major features include email, calendaring, contacts and tasks, support for mobile and web-based access to information, and support for data storage.

213K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo