Forum Moderators: phranque

Message Too Old, No Replies

ssl detection and redirect possible?

Attempt to detect ssl/non-ssl and redirect accordingly

         

edustind

10:20 pm on Nov 8, 2005 (gmt 0)



I am wondering if anyone knows if this is possible.

I have a unique application that will redirect unauthenticated users tcp traffic to a specified IP and Port. Unfortunately, I cannot control mappings. For example, I cannot say any traffic to port 443 redirect to host:8443 and any traffic to 80, redirect to host:8080.

So, what I would like to do is have my apache server be able to understand http and https on the same port, just long enough to initiate a redirect.

For example.

<virtualhost *:8080>
configstuff
SSLEngine on
SSLstuff
</virtualhost>

Then in my documentroot, I use mod_rewrite.
RewriteEngine On
RewriteCond %{HTTPS} ^on
RewriteRule (.*) [myhost...] [R,L]

RewriteCond %{HTTPS}!^on
RewriteRule (.*) [myhost...] [R,L]

The problem is if I am listening for https requests and get an http request, I am immediately sent to a 400 Bad Request page without hitting the re-write rule.

If I am listening for http and get an https request, then of course the server doesn't understand it and I get an error in my browser and we never make it to the rewrite rules either.

Does anyone know a way to make an apache server listen to both http and https on the same port? Perhaps using it as a proxy and specifying to proxy https requests to a certain url and http to a different url? Or any apache modules that can do this? Or any other outside of the box ideas?

Thanks for any help you can provide.

Dusty Dusty