Apache and redirecting http:// to https://

Apache and redirecting http:// to https://

Post by Stephane LARROQU » Fri, 17 May 2002 05:02:02



Hello,

    I am trying to configure an httpd.conf file to allow automatic redirection
for http requests to https ones. This should only be applied on a single
directory which must be accessed using https.

I thought the following lines might do the job :

<Directory /home/httpd/htdocs/X/Y/Z>
     Rewri*gine on
     RewriteCond %{HTTPS} !=on [NC]
     RewriteRule /home/httpd/htdocs/X/(.*) https://%{SERVER_NAME}/$1 [L,R]
</Directory>

I was wrong ! When I try to access "http://my_virtual_host/Y/Z" (using an IP
Virtual Server whose 'DocumentRoot' variable is "/home/httpd/htdocs/X". It
does work. However when I use "http://my_virtual_host/Y/Z/", it does not work
anymore. In the first case I get "https://my_virtual_host/Y/Z/" and therefore
I am redirected. In the second case, no rewritring occures.

Maybe this is a stupid question, but please do not flame. If someone was kind
enough to explain me the whole thing...

Here included is the log file with the two former examples.

IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80bc354][rid#80d808c/initial] (3) [per-dir
/home/httpd/htdocs/X/Y/Z/] applying pattern '/home/httpd/htdocs/X/(.*)$' to
uri '/home/httpd/htdocs/X/Y/Z'
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80bc354][rid#80d808c/initial] (4) RewriteCond:
input='off' pattern='!=on' => matched
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80bc354][rid#80d808c/initial] (2) [per-dir
/home/httpd/htdocs/X/Y/Z/] rewrite /home/httpd/htdocs/X/Y/Z ->
https://my_virtual_host/Y/Z
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80bc354][rid#80d808c/initial] (2) [per-dir
/home/httpd/htdocs/X/Y/Z/] explicitly forcing redirect with
https://my_virtual_host/Y/Z
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80bc354][rid#80d808c/initial] (1) [per-dir
/home/httpd/htdocs/X/Y/Z/] escaping https://my_virtual_host/Y/Z for redirect
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80bc354][rid#80d808c/initial] (1) [per-dir
/home/httpd/htdocs/X/Y/Z/] redirect to https://my_virtual_host/Y/Z [REDIRECT/302]
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80be2b4][rid#80d808c/initial] (3) [per-dir
/home/httpd/htdocs/X/Y/Z/] applying pattern '/home/httpd/htdocs/X/(.*)$' to
uri '/home/httpd/htdocs/X/Y/Z'
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80be2b4][rid#80d808c/initial] (4) RewriteCond: input='on'
pattern='!=on' => not-matched
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80be2b4][rid#80d808c/initial] (1) [per-dir
/home/httpd/htdocs/X/Y/Z/] pass through /home/httpd/htdocs/X/Y/Z
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80be2b4][rid#80d808c/initial] (3) [per-dir
/home/httpd/htdocs/X/Y/Z/] add path-info postfix: /home/httpd/htdocs/X/Y/Z ->
/home/httpd/htdocs/X/Y/Z/
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80be2b4][rid#80d808c/initial] (3) [per-dir
/home/httpd/htdocs/X/Y/Z/] strip per-dir prefix: /home/httpd/htdocs/X/Y/Z/ ->
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80be2b4][rid#80d808c/initial] (3) [per-dir
/home/httpd/htdocs/X/Y/Z/] applying pattern '/home/httpd/htdocs/X/(.*)$' to uri ''
IP1.IP2.IP3.IP4 - - [15/May/2002:22:13:18 +0200]
[my_virtual_host/sid#80be2b4][rid#80d808c/initial] (1) [per-dir
/home/httpd/htdocs/X/Y/Z/] pass through /home/httpd/htdocs/X/Y/Z
IP1.IP2.IP3.IP4 - - [15/May/2002:22:15:55 +0200]
[my_virtual_host/sid#80bc354][rid#80d808c/initial] (3) [per-dir
/home/httpd/htdocs/X/Y/Z/] add path-info postfix: /home/httpd/htdocs/X/Y/Z ->
/home/httpd/htdocs/X/Y/Z/
IP1.IP2.IP3.IP4 - - [15/May/2002:22:15:55 +0200]
[my_virtual_host/sid#80bc354][rid#80d808c/initial] (3) [per-dir
/home/httpd/htdocs/X/Y/Z/] strip per-dir prefix: /home/httpd/htdocs/X/Y/Z/ ->
IP1.IP2.IP3.IP4 - - [15/May/2002:22:15:55 +0200]
[my_virtual_host/sid#80bc354][rid#80d808c/initial] (3) [per-dir
/home/httpd/htdocs/X/Y/Z/] applying pattern '/home/httpd/htdocs/X/(.*)$' to uri ''
IP1.IP2.IP3.IP4 - - [15/May/2002:22:15:55 +0200]
[my_virtual_host/sid#80bc354][rid#80d808c/initial] (1) [per-dir
/home/httpd/htdocs/X/Y/Z/] pass through /home/httpd/htdocs/X/Y/Z

--
______________________________________________________________________________

|   |_  '                             E.N.S. - Departement de Biologie
|_.  _|TEPHANE                        Tel : 0144323635 - Fax : 0144322318

 
 
 

Apache and redirecting http:// to https://

Post by Jorey Bum » Fri, 17 May 2002 05:51:01



> Hello,

>    I am trying to configure an httpd.conf file to allow automatic
> redirection for http requests to https ones. This should only be applied
> on a single directory which must be accessed using https.

   Redirect /somedirectory https://www.ssl.dom

 
 
 

1. http:// and https:// for servlets compiled in apache

Hi,

I have the following query :

For a httpd compiled with the mod_serv and mod_ssl, and using virtual
host for SSL,
with configuration such as the following :

HTTPD.CONF
==========
.
<IfDefine SSL>
  Listen  91
  Listen  92
</IfDefine>
.
.
<VirtualHost xxx.xxx.xxx.xx:92>

   Servername ....
   DocumentRoot .....

   SSL.....
   SSL ......

</VirtualHost>

include /usr/SERVLET/jserv.conf

The servelet programs can both be accessed from
http://xxx.xxx.xxx.xxx:91/servlet
and https://xxx.xxx.xxx.xxx:92/servlet

which defeats the purpose of using SSL in the first place.

If I still want to be able to listen to 2 different ports , 1 for
non-secure and 1 for secure, and both cannot accesss each other programs
...and still using only 1 HTTPD , how can this be done ?

Regards,
Keok Tay

2. Print to Network Printers

3. apache-ssl: how to setup two versions of server, http:// and https:// ?

4. ppp daemon dies!

5. http:// does work but https://

6. ulimit cannot modify

7. https:// to http:// by ProxyPass

8. adaptec aha-1540A?

9. Why flushing buffer works w/ http:// but not https://

10. redirect to http:// to http://www

11. Redirecting ftp:* to http://... (Cern 3.0)

12. Redirecting http://a.b.c/foo to http://a.b.c/foo/ (NCSA httpd 1.4.2)

13. Can Apache Proxy https://