You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Tarun Narang <Ta...@Xchanging.com> on 2009/04/20 06:47:50 UTC

[users@httpd] Redirecting request from HTTP to HTTPS

Hi,

 

How could I redirect all my requests for http to https ?

 

Our application was running on oracle application server having inbuilt
Apache HTTP server 1.3. It was recommended to us to upgrade the modules 

of apache (like SSL, open SSL, perl and others) without upgrade the
oracle application server. 

Given the above situation, it was not possible to upgrade the apache
modules without upgrade the oracle application server.

Then We decided to introduce a proxy server (Apache 2.2) 

which will receive all the incoming requests and forward them to the
existing Oracle Apache Server 1.3. 

To do these changes, SSL was implemented on port 4430 and non SSL
request to be recieved at 8080 for Apache 2.2. 

Now Apache Server 2.2 receive all the requests on port 8080 and redirect
the requests to the existing server 1.3

(which is reconfigured to run on a new port 8082 and SSL port 443).

 

Now I am able to redirect all my non SSL requests for port 8080 to 8082
by putting the below entry in httpd.conf file:

 

LoadModule proxy_module modules/mod_proxy.so

ProxyRequests Off

<Proxy *>

Order deny,allow

Allow from all

</Proxy>

 

ProxyPass /hsbc http://localhost:8082/hsbc

 

Now when I do the request from browser like this -
http://localhost:8080/hsbc it redirects it to
http://localhost:8082/hsbc. 

However, I have to redirect the non SSL request to SSL request, like
when the user requests for http://localhost:8080/hsbc it should be
redirected to 

https://localhost:4430/hsbc which should redirect it to
https://localhost:443/hsbc. We cannot directly redirect the SSL requests
to Apache 1.3

because we have to use the upgraded modules present at apache 2.2 and
not 1.3.

 

Please help how could I redirect the http request to https as mentioned
aforesaid.

 

Regards,

Tarun Narang

 

CONFIDENTIALITY NOTICE

This message and any attachment are confidential and may also be
privileged. If you are not the intended recipient of this e-mail you may
not copy, forward, disclose or otherwise use it or any part of it in any
form whatsoever. If you are not the intended recipient please telephone
or e-mail the sender and delete this message and any attachment from
your system.

 


Re: [users@httpd] Redirecting request from HTTP to HTTPS

Posted by Krist van Besien <kr...@gmail.com>.
On Tue, Apr 21, 2009 at 6:48 AM, Tarun Narang
<Ta...@xchanging.com> wrote:

> By using the rewrite engine rule and the proxy settings specified below,
> I am able to receive the entire http request to https. Please have a
> look and let me know, I understood you correctly or not this time.
>
> LoadModule proxy_module modules/mod_proxy.so
> ProxyRequests Off
> <Proxy *>
> Order deny,allow
> Allow from all
> </Proxy>
> ProxyPass /hsbc http://localhost:8082/hsbc
>
> LoadModule rewrite_module modules/mod_rewrite.so
> RewriteEngine On
> RewriteCond %{HTTPS} !=on
> RewriteRule ^/(.*) https://%{SERVER_NAME}:4430/$1 [L,R]

That should indeed work. If a browser contacts your server using http
it is instructed to use https in stead, and everything is then proxied
to your old server. if this fits your requirements I'd keep it like
that.

Krist


-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Redirecting request from HTTP to HTTPS

Posted by Tarun Narang <Ta...@Xchanging.com>.
Thanks Krist, for looking in to this and providing a brief description.

Yes, you understood the problem correctly and I was wrong by asking to
remove the proxy. I cannot get rid off the proxy server.

Have your frontend forward both http and https requests to the http
port on your backend. This config also makes it possible to run your
frontend on the standard http and https ports.

By using the rewrite engine rule and the proxy settings specified below,
I am able to receive the entire http request to https. Please have a
look and let me know, I understood you correctly or not this time.

LoadModule proxy_module modules/mod_proxy.so
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /hsbc http://localhost:8082/hsbc

LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On 
RewriteCond %{HTTPS} !=on 
RewriteRule ^/(.*) https://%{SERVER_NAME}:4430/$1 [L,R]


Regards
Tarun

-----Original Message-----
From: Krist van Besien [mailto:krist.vanbesien@gmail.com] 
Sent: Monday, April 20, 2009 8:34 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Redirecting request from HTTP to HTTPS

On Mon, Apr 20, 2009 at 1:50 PM, Tarun Narang
<Ta...@xchanging.com> wrote:
> Hi Krist
>
> Thanks Krist, I got your point.

I have the impression you didn't.

> Now, If I remove the proxy and go for redirect. In that case, how
could
> I redirect the http request to https://localhost:4430/hsbc which
should
> redirect it to https://localhost:443/hsbc. I cannot directly redirect
> the SSL requests to Apache 1.3 because we have to use the upgraded
> modules present at apache 2.2 and not 1.3.

Redirect means:

1) Browser requests http://somehost.com/someurl.
2) Server answers with "this resource is not available here, but is
available at http://someotherhost.com/someurl
3) Broswer now requests http://someotherhost.com/someurl. previous
host is no longer involved.


Proxy means:
1) Browser requests http://somehost.com/someurl.
2) Server is configured to pass this request on to someotherhost.com
3) server gets respons from someotherhost.com
4) server returns respons to browser.

Redirecting is done with the directives that start with "Redirect".
Proxyin is done using the statements that start with "Proxy".

See the manuals.

>From your information I guess your situation is the following:
-  You have Oracle Application server, with an integrated apache 1.3,
this is your "backend".
- You have an apache 2.2 as your "frontend"

The "Frontend" needs to forward requests to the "backend". You have
this working for http, but not for https, right?

now, my first suggestion would be the following:

- If it is your intention to have the "frontend" receive all requests,
and forward then to the backend, why not just disable SSL on the
backend. Since they appear both on the same machines you really don't
need to secure communication between them.
- Have your frontend forward both http and https requests to the http
port on your backend. This config also makes it possible to run your
frontend on the standard http and https ports.

Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server
Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Redirecting request from HTTP to HTTPS

Posted by Krist van Besien <kr...@gmail.com>.
On Mon, Apr 20, 2009 at 1:50 PM, Tarun Narang
<Ta...@xchanging.com> wrote:
> Hi Krist
>
> Thanks Krist, I got your point.

I have the impression you didn't.

> Now, If I remove the proxy and go for redirect. In that case, how could
> I redirect the http request to https://localhost:4430/hsbc which should
> redirect it to https://localhost:443/hsbc. I cannot directly redirect
> the SSL requests to Apache 1.3 because we have to use the upgraded
> modules present at apache 2.2 and not 1.3.

Redirect means:

1) Browser requests http://somehost.com/someurl.
2) Server answers with "this resource is not available here, but is
available at http://someotherhost.com/someurl
3) Broswer now requests http://someotherhost.com/someurl. previous
host is no longer involved.


Proxy means:
1) Browser requests http://somehost.com/someurl.
2) Server is configured to pass this request on to someotherhost.com
3) server gets respons from someotherhost.com
4) server returns respons to browser.

Redirecting is done with the directives that start with "Redirect".
Proxyin is done using the statements that start with "Proxy".

See the manuals.

>From your information I guess your situation is the following:
-  You have Oracle Application server, with an integrated apache 1.3,
this is your "backend".
- You have an apache 2.2 as your "frontend"

The "Frontend" needs to forward requests to the "backend". You have
this working for http, but not for https, right?

now, my first suggestion would be the following:

- If it is your intention to have the "frontend" receive all requests,
and forward then to the backend, why not just disable SSL on the
backend. Since they appear both on the same machines you really don't
need to secure communication between them.
- Have your frontend forward both http and https requests to the http
port on your backend. This config also makes it possible to run your
frontend on the standard http and https ports.

Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Redirecting request from HTTP to HTTPS

Posted by Tarun Narang <Ta...@Xchanging.com>.
Hi Krist

Thanks Krist, I got your point.
Now, If I remove the proxy and go for redirect. In that case, how could
I redirect the http request to https://localhost:4430/hsbc which should
redirect it to https://localhost:443/hsbc. I cannot directly redirect
the SSL requests to Apache 1.3 because we have to use the upgraded
modules present at apache 2.2 and not 1.3.

Regards
Tarun

-----Original Message-----
From: Krist van Besien [mailto:krist.vanbesien@gmail.com] 
Sent: Monday, April 20, 2009 4:29 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Redirecting request from HTTP to HTTPS

On Mon, Apr 20, 2009 at 6:47 AM, Tarun Narang
<Ta...@xchanging.com> wrote:



> Please help how could I redirect the http request to https as
mentioned
> aforesaid.

First you need to make clear to us if you want to "redirect" requests,
or if you want to "proxy" them. These two things are fundamentally
different. You use the term "redirect" in your explanation, but in
your examples you are proxying.

Proxying http -> https is something apache doesn't do out of the box.
It is alos something you might not need. It's pretty pointless to
secure the internal part of a communication when you're not securing
the external part.

Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server
Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Redirecting request from HTTP to HTTPS

Posted by Krist van Besien <kr...@gmail.com>.
On Mon, Apr 20, 2009 at 6:47 AM, Tarun Narang
<Ta...@xchanging.com> wrote:



> Please help how could I redirect the http request to https as mentioned
> aforesaid.

First you need to make clear to us if you want to "redirect" requests,
or if you want to "proxy" them. These two things are fundamentally
different. You use the term "redirect" in your explanation, but in
your examples you are proxying.

Proxying http -> https is something apache doesn't do out of the box.
It is alos something you might not need. It's pretty pointless to
secure the internal part of a communication when you're not securing
the external part.

Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Redirecting request from HTTP to HTTPS

Posted by Scott Gifford <sg...@suspectclass.com>.
"Tarun Narang" <Ta...@Xchanging.com> writes:

> How could I redirect all my requests for http to https ?

Hello Tarun,

We use RedirectMatch for this.  See:

    http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirectmatch

> However, I have to redirect the non SSL request to SSL request, like when the
> user requests for http://localhost:8080/hsbc it should be redirected to

Try something like this:

    RedirectMatch ^/hsbc(.*)$ https://localhost:4430/hsbc$1

I hope this helps, I'm not sure I understood exactly what you were
asking in your message.

Good luck!

----Scott.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org