Redirection to ssl webmail

Discussion forum for Enterprise Edition.
Post Reply
support_tech2
Posts: 1
Joined: Wed Apr 10, 2013 10:46 pm

Redirection to ssl webmail

Post by support_tech2 » Wed Apr 10, 2013 11:39 pm

Hello,

I have just installed an SSL cert on our webmail server and it is working fine. How can I redirect the old webmail (from port 80) to the new secure site (port 443)?
i.e. when a user goes to http://webmail.example.com we want them to auto redirect to https://webmail.example.com. I created a .asp redirect file with <% Response.Redirect https://webmail.example.com %> , and put it in the default directory. When i accessed the webmail online, it displayed the contents of the asp file instead of redirecting. I also tried redirecting using IIS (inside the redirect html section), but that broke both sites as well.

We would also like to add a second site to IIS for all other clients and brand that with a generic URL – so all other hosted domains could check their email.

If anyone has any ideas on how to accomplish these two things, your help would be appreciated.

Thanks

dreniarb
Posts: 316
Joined: Mon Jan 19, 2004 5:00 pm
Location: Marion, IN

Re: Redirection to ssl webmail

Post by dreniarb » Thu Apr 11, 2013 11:21 am

It sounds to me like you've gone about it the correct ways, but something is not correct in your IIS configuration. I use a php redirect to forward people from webmail.example.com to the https site, but i would think asp would be just fine. if it's showing the code of your asp file i'd think there is surely something misconfigured in IIS.

frontdist
Posts: 17
Joined: Tue Mar 05, 2013 7:12 pm

Re: Redirection to ssl webmail

Post by frontdist » Thu Apr 11, 2013 6:50 pm

The only way I was able to accomplish this was to use some trickery in IIS.

I added the site mail.yourdomain.com to IIS, then installed the webmail service. Because I could not figure out how to get it to load the default ASP application (webmail) I had it do a redirect. Under the HTTP Redirect tab, I selected "Redirect requests to this destination" and entered "/MEWebMail/"

Then, under redirect behaviour I selected "Only redirect requests to content in this directory (not subdirectories)" with status code Permanent (301)

To get HTTPS to I had to go to SSL Settings and check "require ssl" which then gives an error when you try to load http://mail.yourdomain.com instead of https://mail.yourdomain.com

Then finally to complete the shenanigans, I went to "error pages" and under status code 403 (the deault error given when you go http:// instead of https:// on a SSL-forced site) and for the path, I put in the full site https://mail.yourdomain.com

The chain looks like this...

user browses to mail.yourdomain.com, in the background the 403 error occurs and then redirects to https://mail.yourdomain.com then once there, it redirects to the directory /MEWebMail/ so the correct application loads and the user can log in.

Please let me know if this works!

WinterPeg man
Posts: 48
Joined: Wed Jul 20, 2005 1:06 am

Re: Redirection to ssl webmail

Post by WinterPeg man » Fri Jul 05, 2013 4:10 pm

frontdist wrote:The only way I was able to accomplish this was to use some trickery in IIS.

I added the site mail.yourdomain.com to IIS, then installed the webmail service. Because I could not figure out how to get it to load the default ASP application (webmail) I had it do a redirect. Under the HTTP Redirect tab, I selected "Redirect requests to this destination" and entered "/MEWebMail/"

Then, under redirect behaviour I selected "Only redirect requests to content in this directory (not subdirectories)" with status code Permanent (301)

To get HTTPS to I had to go to SSL Settings and check "require ssl" which then gives an error when you try to load http://mail.yourdomain.com instead of https://mail.yourdomain.com

Then finally to complete the shenanigans, I went to "error pages" and under status code 403 (the deault error given when you go http:// instead of https:// on a SSL-forced site) and for the path, I put in the full site https://mail.yourdomain.com

The chain looks like this...

user browses to mail.yourdomain.com, in the background the 403 error occurs and then redirects to https://mail.yourdomain.com then once there, it redirects to the directory /MEWebMail/ so the correct application loads and the user can log in.

Please let me know if this works!

This was the ONLY way I could get this to work on IIS 8!! I tried the javascript redirect, and everything else (aspx, etc. etc.)

THANK YOU!!!!!!

crittle1
Posts: 99
Joined: Sun Nov 10, 2013 10:01 pm

Re: Redirection to ssl webmail

Post by crittle1 » Thu Mar 19, 2015 6:49 am

I was able to get a https redirect working by the following.. ( IIS 7 Windows 2008 Server )

1. Navigate to Your IIS Manager > Sites > Site name
2. SSL Settings > Check "Require SSl " & "Require 128-bit SSL" then choose Ignore for certificates.
3. Go to Mail Enable > bin > NETWebMail
4. Make a backup of your web config to your desktop just incase.
5. Open the original web config file
6. Add the following lines to the bottom of the page in between the <system.webServer> tags.
7. Save Close Test
8. When you upgrade to a new version, this code will probably be overwritten, so just remember to add it again if necessary.
8. Note: I installed URL Rewrite extension in the IIS first. I didn't do anything in the URL Rewrite except install it and then followed instructions 1-7 above. It's shouldn't matter if you install it after the fact if the steps 1-7 doesn't work first. The URL Rewrite is new to me, but it seems to pick up the code from the config file and shows it in the IIS manager area for the website.This extension is for IIS 7.x and higher. http://www.iis.net/downloads/microsoft/url-rewrite

Code: Select all

<rewrite>


<rules>

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
  <match url="(.*)" />
    <conditions>
      <add 

input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
  <action type="Redirect" redirectType="Found" 

url="https://{HTTP_HOST}/{R:1}" />
</rule>

</rules>

</rewrite>


pmnit
Posts: 42
Joined: Mon Jun 20, 2011 8:32 pm
Location: Louisville, KY

Re: Redirection to ssl webmail

Post by pmnit » Mon Sep 21, 2015 6:14 pm

I just used Crittle1's suggestion. I had originally had this working in some "odd" way with an index.html file running a redirect from the default website to the https of the webmail site. That worked for a long time. But something got messed up during the latest SSL cert update. So I tried crittle1's suggestion. It did not work at first. But I made some adjustments and got it working.

Here is what I did.

Go to Go to Mail Enable > bin > NETWebMail folder and make a backup of your web.config file.

NOTE: I skipped step 7. (SSL Settings > Check "Require SSl " & "Require 128-bit SSL" then choose Ignore for certificates.)

Then followed the instructions for installing and configuring the URL ReWrite extension from (http://www.jppinto.com/2010/03/automati ... write-2-0/).

I used the GUI to configure URL ReWrite and added a new rule. While trying to add the rule there is a section where you add a redirect URL of "https://{HTTP_HOST}/{R:1]" . However, the "1" would not work for me. In my case I needed to add a "0" instead.

After that I was able to apply the rule to the site and the redirect began working perfectly. URL ReWrite added the following code to my web.config file.

I just used Crittle1's suggestion. I had originally had this working in some "odd" way with an index.html file running a redirect from the default website to the https of the webmail site. That worked for a long time. But something got messed up during the latest SSL cert update. So I tried crittle1's suggestion. It did not work at first. But I made some adjustments and got it working.

Here is what I did.

Go to Go to Mail Enable > bin > NETWebMail folder and make a backup of your web.config file.

NOTE: I skipped step 7. (SSL Settings > Check "Require SSl " & "Require 128-bit SSL" then choose Ignore for certificates.)

Then followed the instructions for installing and configuring the URL ReWrite extension from (http://www.jppinto.com/2010/03/automati ... write-2-0/).

I used the GUI to configure URL ReWrite and added a new rule. While trying to add the rule there is a section where you add a redirect URL of "https://{HTTP_HOST}/{R:1]" . However, the "1" would not work for me. In my case I needed to add a "0" instead.

After that I was able to apply the rule to the site and the redirect began working perfectly. URL ReWrite added the following code to my web.config file.

Code: Select all

<rewrite>
            <rules>
                <rule name="Redirect to HTTPS" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:0}" redirectType="SeeOther" />
                </rule>
            </rules>
        </rewrite>


webshaun
Posts: 246
Joined: Wed May 25, 2005 8:37 pm
Location: NJ
Contact:

Re: Redirection to ssl webmail

Post by webshaun » Sun Nov 06, 2016 6:28 am

This is probably a bit more modern, utilizing HSTS.

Code: Select all

<system.webServer>
        <rewrite>
            <rules>
                <rule name="HTTP to HTTPS redirect" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}"
                        redirectType="Permanent" />
                </rule>
            </rules>
            <outboundRules>
                <rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
                    <match serverVariable="RESPONSE_Strict_Transport_Security"
                        pattern=".*" />
                    <conditions>
                        <add input="{HTTPS}" pattern="on" ignoreCase="true" />
                    </conditions>
                    <action type="Rewrite" value="max-age=31536000" />
                </rule>
            </outboundRules>
        </rewrite>
  </system.webServer>
---
Shaun Rieman
Advanced Micro Technologies, LLC

Post Reply