Subject: directing http --> https

From: "Farooq Khan (Contractor - Production Services)" <[email-masked]>
Date: Thu, 7 Feb 2002 10:18:26 -0000

Hi,
 
I hope this is the correct forum for my query.
 
I have installed apache with mod_ssl.  Briefly, I want all http requests
to a particular VirtualHost to be redirected to https for the same
VirtualHost.  Do I use mod_rewrite to do this?
 
I have set up 4 VirtualHosts in the order:
<VirtualHost a.com:80>
<VirtualHost b.com:80>
<VirtualHost c.com:80>
<VirtualHost d.com:443>
All https://d.com <https://d.com/>  requests work fine.  I want all
http://d.com <http://d.com/>  to be redirected to https://d.com
<https://d.com/>  but they are defaulting to http://a.com
<http://a.com/> .
 
I guess one solution might be to place the <VirtualHost d.com:443>
container at the top of the VirtualHost container list in httpd.conf but
I want the general default to be a.com:80.
 
I thought this would be straightforward but I dunno how to do it.
 
Appreciate any help.  Cheers,
 
Farooq Khan
Mob: +44 7771 981 946
Email: [email-masked]

-----------------------------------------------------------------
This message is for the designated recipient only and may contain
privileged or confidential information. If you have received it
in error, please notify the sender immediately and delete the 
original. Any other use of the email by you is prohibited.

---

From: Owen Boyle <[email-masked]>
Date: Thu, 07 Feb 2002 12:46:37 +0100

"Farooq Khan" writes:

> I have installed apache with mod_ssl.  Briefly, I want all http requests to a particular
> VirtualHost to be redirected to https for the same VirtualHost.  Do I use mod_rewrite to do
> this?
> 
>  
> 
> All https://d.com requests work fine.  I want all http://d.com to be redirected to
> https://d.com but they are defaulting to http://a.com.
> 

The trouble is you haven't defined anything for requests on port 80 with
ServerName = "d.com" so apache just serves the first port 80 VH it finds
- in this case a.com.

The solution is to create a small VH for d.com:80 and fill it with just
a Redirect to the https site, e.g.

<VirtualHost d.com:80>
  ServerName d.com
  Redirect / https://d.com/
</VirtualHost>

This will bounce any request to d.com to the top of the https site. If
you want to be more specific so that http://d.com/foo/bar.html -->
https://d.com/foo/bar.html then use something like:

RedirectMatch (.*) https://d.com$1

Read the docs for these directives for more details. You can do a lot
with redirects and you only need to use rewrites if things get really
complicated.

Rgds,

Owen Boyle.
______________________________________________________________________
Apache Interface to OpenSSL (mod_ssl)                   www.modssl.org
User Support Mailing List                      [email-masked]
Automated List Manager                            [email-masked]

---

From: Owen Boyle <[email-masked]>
Date: Thu, 07 Feb 2002 12:46:37 +0100

<VirtualHost d.com:80>
  ServerName d.com

Rgds,

Owen Boyle.

---

From: [email-masked]
Date: Fri, 8 Feb 2002 17:57:50 +0800

Quoting Owen Boyle <[email-masked]>:

> If you want to be more specific so that 
> http://d.com/foo/bar.html --> https://d.com/foo/bar.html
> then use something like:
> 

Won't this create an infinate loop? 
I could be wrong, but I think RedirectMatch will pick up the hit via http or https, and attempt to send the user to https://d.com$1 even if the user came via https in the first place.

mod_rewrite seems to be the only alternative I've seen so far. If I'm wrong, let me know...

---

From: Owen Boyle <[email-masked]>
Date: Mon, 11 Feb 2002 09:29:28 +0100

> I could be wrong, but I think RedirectMatch will pick up the hit via http or https, and attempt to send the user to https://d.com$1 even if the user came via https in the first place.

It depends on the "context" - i.e. where you put the directive in the
httpd.conf file. If you put it outside of any virtualhost container it
will have "server-config" context which means it will apply globally to
all VHs. Then you will have trouble... 

However, if you have virtualhosts defined and you put the directive
inside a VH container, it will have "virtualhost" context which means
that it will only apply to that VH. 

Since you are using VHs, you must put the directive inside the plain
HTTP VH for "d.com". Then it will only apply to HTTP requests to d.com.

> mod_rewrite seems to be the only alternative I've seen so far. If I'm wrong, let me know...

mod_rewrite is great and I'm a big fan, but it is a sledge-hammer to
crack a nut in this instance.

Rgds,

Owen Boyle.

---

From: "Santosh Deshpande" <[email-masked]>
Date: Mon, 11 Feb 2002 15:09:22 -0000

hi all,
  I would like to know whether a SSL certificate is issued to a specific
domain?
  Can I run have two vhosts configured with a single certificate
  e.g. www.mydomain.com  ( 213.x.x.x:443)
  and  sub.mydomain.com  ( 213.x.x.y:443)

regards,
Santosh

---

From: "Jose Torres" <[email-masked]>
Date: Mon, 18 Feb 2002 22:23:39 -0500

Hi, all, I am looking for this response. If there was one, I also need
to know if it is possible to run two vhosts with a single certificate?
TIA

-----Original Message-----
From: [email-masked]
[mailto:[email-masked]] On Behalf Of Santosh Deshpande
Sent: Monday, February 11, 2002 10:09 AM
To: [email-masked]
Subject: Certificate

hi all,

regards,
Santosh

---

From: NickM <[email-masked]>
Date: Tue, 19 Feb 2002 08:54:34 +0100 (CET)

>   I would like to know whether a SSL certificate is issued to a

yes

>   and  sub.mydomain.com  ( 213.x.x.y:443)

only if it is a wild card certificate, i.e. *.mydomain.com
anything else would bring up a message saying its not for that domain but would 
still work.

Nick