From: Bill Moseley 
  > 2010/3/25 Octavian Rasnita <orasn...@gmail.com>

    > > The back end servers don't know if the current request is an http or an 
https one and on each redirect, > > they do the redirection using the http 
scheme.
    > > (I have also set the configuration option using_frontend_proxy to true.)
    > > 
    > > Also, because the back end servers receive only http requests, 
$c->req->secure is always equal to 0.
    > > I have read that I can set the HTTPS environment variable to "On" and I 
put the following line in the 
    > > configuration file of the load balancer Apache server in the 
virtualhost that handles SSL requests:
    > > 
    > > SetEnv HTTPS On



  > Does that header get to Catalyst?  Obviously, check that first.
  > 

  > I have this in  a "after 'prepare_headers'":
  > 

  >    $res->secure( 1 ) if lc( $req->header( 'Https' ) || '' ) eq 'on';
  > 
  > The load balancer sends all traffic to the same port.  The load balancer 
sets that header for SSL traffic.


  I didn't know that HTTPS should be an HTTP header and not an environment 
variable so I have also added as a header.

  I have put in the configuration file of the back end servers (to be sure that 
it will reach the app):

  SetEnv HTTPS On

  and in the configuration file of the load balancer server:

  RequestHeader set HTTPS On

  And in a test action I have done:

  my $body;
  $body .= "HTTPS environment variable: $ENV{HTTPS}<br />\n";
  $body .= "HTTPS header: " . $c->req->header('HTTPS') . "<br />\n";
  $body .= "secure: " . $c->req->secure . "<br />\n";;
  $c->req->secure(1); #Force it to be true
  $body .= "secure: " . $c->req->secure . "<br />\n"; # Check if it is set 
correctly
  $body .= "uri_for_action: " . $c->uri_for_action('/user/login2') . "<br />\n";
  $c->res->body($body);

  And the result is:

  HTTPS environment variable: On
  HTTPS header: On
  secure: 0
  secure: 1
  uri_for_action: http://site.testsite.com:5555/en/user/login2

  So it seems that both the environment variable HTTPS and the header HTTPS are 
seen by Catalyst, but $c->req->secure is still equal to 0.

  Do I need to add a certain plugin in order to be able to use $c->req->secure 
or what could be the problem that it is not set correctly?

  I have read in Catalyst::Request:

  "the URI scheme (eg., http vs. https) must be determined through heuristics; 
depending on your server configuration, it may be incorrect. See $req->secure 
for more info."

  And more info:
  "Note that the URI scheme (eg., http vs. https) must be determined through 
heuristics, and therefore the reliablity of $req->secure will depend on your 
server configuration. If you are serving secure pages on the standard SSL port 
(443) and/or setting the HTTPS environment variable, $req->secure should be 
valid."

  I am accessing the site using SSL by the 5555 port so I need the HTTPS 
environment variable (or HTTP header) but I don't know why $c->req->secure is 
still not set.

  And finally, even though I forced $c->req->secure to be true, 
$c->uri_for_action still uses the http scheme and not https so in the entire 
application the redirects won't be done correctly and this is the big problem.

  Thanks.


  Octavian


  -- 
  Bill Moseley
  mose...@hank.org



------------------------------------------------------------------------------


  _______________________________________________
  List: Catalyst@lists.scsys.co.uk
  Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
  Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
  Dev site: http://dev.catalyst.perl.org/



  __________ Information from ESET NOD32 Antivirus, version of virus signature 
database 4975 (20100325) __________

  The message was checked by ESET NOD32 Antivirus.

  http://www.eset.com




__________ Information from ESET NOD32 Antivirus, version of virus signature 
database 4975 (20100325) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to