HTTP --> HTTPS rewrite not working

HTTP --> HTTPS rewrite not working

am 18.01.2003 05:39:12 von lists

Greetz all,

I'm trying to force one of my virtual hosts to use https when http is
requested by a mod_rewrite rule. I am testing the implementation using
curl.

When I specify https in my url, curl will grab the correct page:

[root@molodetz:~]# curl https://family.sancho2k.net





Sancho2k.net Family - Our family web page

But when I throw http://family.sancho2k.net ...

[root@molodetz:~]# curl http://family.sancho2k.net


This is my VirtualHost configuration:

NameVirtualHost 10.0.0.40:443

ServerName family.sancho2k.net
DocumentRoot /var/www/htdocs/fam_public_html
ServerAdmin sancho@sancho2k.net
CustomLog logs/family/access_log combined
ErrorLog logs/family/error_log
TransferLog logs/family/ssl_access_log
LogLevel debug
SSLEngine on
SSLCertificateFile /var/www/conf/certs/family/server.crt
SSLCertificateKeyFile /var/www/conf/certs/family/server.key
UseCanonicalName off
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]
#SSLVerifyClient require
#SSLVerifyDepth 1
#SSLCACertificateFile conf/certs/cacert.crt


Why is it redirecting my requests to www.sancho2k.net? This is a
seperate virtual host I have set up:

NameVirtualHost 10.0.0.2:80

ServerName www.sancho2k.net
DocumentRoot /var/www/htdocs
ServerAdmin webmaster@sancho2k.net
SSLEngine off



Thanks in advance for help.

DS

____________________________________________________________ __________
Apache Interface to OpenSSL (mod_ssl) www.modssl.org
User Support Mailing List modssl-users@modssl.org
Automated List Manager majordomo@modssl.org

Re: HTTP --> HTTPS rewrite not working

am 18.01.2003 08:10:32 von jeff

Well, you have the ReWrite rule INSIDE the destination SSL VH config.. A
bit useless..

The ReWrite needs to be inside the VH configs that NEED to redirect - such
as 10.0.0.40:80, Servername family.sancho2k.net

As for why http://family.sancho2k.net is sending a webpage with a meta-tag
redirect - What is actually being server for that address ???
It is probably your default page you have put there..

Rgds
Jeff

----- Original Message -----
From: "Sancho2k.net Lists"
To:
Sent: Saturday, January 18, 2003 2:39 PM
Subject: HTTP --> HTTPS rewrite not working


> Greetz all,
>
> I'm trying to force one of my virtual hosts to use https when http is
> requested by a mod_rewrite rule. I am testing the implementation using
> curl.
>
> When I specify https in my url, curl will grab the correct page:
>
> [root@molodetz:~]# curl https://family.sancho2k.net
>
>
>
>
>
> Sancho2k.net Family - Our family web page
>
> But when I throw http://family.sancho2k.net ...
>
> [root@molodetz:~]# curl http://family.sancho2k.net
>
>
> This is my VirtualHost configuration:
>
> NameVirtualHost 10.0.0.40:443
>
> ServerName family.sancho2k.net
> DocumentRoot /var/www/htdocs/fam_public_html
> ServerAdmin sancho@sancho2k.net
> CustomLog logs/family/access_log combined
> ErrorLog logs/family/error_log
> TransferLog logs/family/ssl_access_log
> LogLevel debug
> SSLEngine on
> SSLCertificateFile /var/www/conf/certs/family/server.crt
> SSLCertificateKeyFile /var/www/conf/certs/family/server.key
> UseCanonicalName off
> RewriteEngine on
> RewriteCond %{SERVER_PORT} !^443$
> RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]
> #SSLVerifyClient require
> #SSLVerifyDepth 1
> #SSLCACertificateFile conf/certs/cacert.crt
>

>
> Why is it redirecting my requests to www.sancho2k.net? This is a
> seperate virtual host I have set up:
>
> NameVirtualHost 10.0.0.2:80
>
> ServerName www.sancho2k.net
> DocumentRoot /var/www/htdocs
> ServerAdmin webmaster@sancho2k.net
> SSLEngine off
>

>
>
> Thanks in advance for help.
>
> DS
>
> ____________________________________________________________ __________
> Apache Interface to OpenSSL (mod_ssl) www.modssl.org
> User Support Mailing List modssl-users@modssl.org
> Automated List Manager majordomo@modssl.org
>

____________________________________________________________ __________
Apache Interface to OpenSSL (mod_ssl) www.modssl.org
User Support Mailing List modssl-users@modssl.org
Automated List Manager majordomo@modssl.org

Re: HTTP --> HTTPS rewrite not working

am 18.01.2003 11:29:48 von Mads Toftum

On Fri, Jan 17, 2003 at 09:39:12PM -0700, Sancho2k.net Lists wrote:
> NameVirtualHost 10.0.0.40:443
>
[SNIP]
> RewriteEngine on
> RewriteCond %{SERVER_PORT} !^443$

This will never happen because you're already inside the Port 443
vhost container.
>
> NameVirtualHost 10.0.0.2:80
>
> ServerName www.sancho2k.net

Redirect / https://family.sancho2k.net

No real need to use mod_rewrite for that.

vh

Mads Toftum
--
`Darn it, who spiked my coffee with water?!' - lwall

____________________________________________________________ __________
Apache Interface to OpenSSL (mod_ssl) www.modssl.org
User Support Mailing List modssl-users@modssl.org
Automated List Manager majordomo@modssl.org

Re: HTTP --> HTTPS rewrite not working

am 19.01.2003 23:55:55 von lists

Mads Toftum wrote:
> This will never happen because you're already inside the Port 443
> vhost container.

Stupid oversight on my behalf. Thanks to those that pointed this out.

>
>>NameVirtualHost 10.0.0.2:80
>>
>> ServerName www.sancho2k.net
>
>
> Redirect / https://family.sancho2k.net
>
> No real need to use mod_rewrite for that.

And it works with the simple redirect. Surprisingly, most of the howtos
and internet resources I find suggest using mod_rewrite to direct all
requests to the SSL site. Thanks for the clarification.

>
> vh
>
> Mads Toftum

____________________________________________________________ __________
Apache Interface to OpenSSL (mod_ssl) www.modssl.org
User Support Mailing List modssl-users@modssl.org
Automated List Manager majordomo@modssl.org