Koozali.org: home of the SME Server

Redirect ibay to use https

Offline mikalof

  • **
  • 27
  • +0/-0
Redirect ibay to use https
« on: April 26, 2011, 11:36:10 AM »
Hello, I found this howto, http://wiki.contribs.org/Https_redirection, that states it will force https redirection of an ibay but I cannot get it working. The only thing it does is deny http, still allowing https.
If this Howto is wrong then is there another way of forcing https (redirect from http) in an ibay?

Offline imcintyre

  • *
  • 609
  • +0/-0
Re: Redirect ibay to use https
« Reply #1 on: April 26, 2011, 12:11:27 PM »
Perhaps wording is not correct; isn't this what you wanted, "deny http, https still working"?

Offline mikalof

  • **
  • 27
  • +0/-0
Re: Redirect ibay to use https
« Reply #2 on: April 26, 2011, 12:18:18 PM »
Perhaps wording is not correct; isn't this what you wanted, "deny http, https still working"?
To be even more clear, I want redirection of http to https, per ibay. Not just deny http.
The Howto claims to redirect but not for me.

Offline johnp

  • *****
  • 312
  • +0/-0
Re: Redirect ibay to use https
« Reply #3 on: April 26, 2011, 01:25:06 PM »
Did you try Ray Mitchell's method? It's the first link at the top of that how to.

Offline mikalof

  • **
  • 27
  • +0/-0
Re: Redirect ibay to use https
« Reply #4 on: April 26, 2011, 01:55:00 PM »
Did you try Ray Mitchell's method? It's the first link at the top of that how to.
Aren't they both Ray's? However I used the later one since the earlier seemed quite old. They also seem to be set up to work quite differently. I could give the older version a try but would prefer the later because it has a db setting for enabling/disabling per ibay.

Offline johnp

  • *****
  • 312
  • +0/-0
Re: Redirect ibay to use https
« Reply #5 on: April 26, 2011, 01:58:27 PM »
I don't think the later was done by Ray. From what I can tell, the later only denys access like you said.

Offline mikalof

  • **
  • 27
  • +0/-0
Re: Redirect ibay to use https
« Reply #6 on: April 26, 2011, 02:12:53 PM »
I don't think the later was done by Ray. From what I can tell, the later only denys access like you said.


Tried the earlier version and it works! Thanks for "redirecting" me :-)

Well, if the later version isn't even supposed to redirect then why is it in a howto called "Https redirection"? I guess it should be called "Deny plain http" or "Require SSL" and posted separately.

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Redirect ibay to use https
« Reply #7 on: April 26, 2011, 02:14:44 PM »

Tried the earlier version and it works! Thanks for "redirecting" me :-)

Well, if the later version isn't even supposed to redirect then why is it in a howto called "Https redirection"? I guess it should be called "Deny plain http" or "Require SSL" and posted separately.

if something is wrong with the documentation please open a bug or, better, register and edit the wiki page

Offline johnp

  • *****
  • 312
  • +0/-0
Re: Redirect ibay to use https
« Reply #8 on: April 26, 2011, 02:29:24 PM »
Stefano, I was going to suggest that :)

Either way, I hope the OP found it a learning experience.

Offline mikalof

  • **
  • 27
  • +0/-0
Redirect ibay to use https
« Reply #9 on: April 26, 2011, 03:35:50 PM »

Offline johnp

  • *****
  • 312
  • +0/-0
Re: Redirect ibay to use https
« Reply #10 on: April 27, 2011, 02:59:37 AM »
If you want to have something the can be controlled with a db setting, somthing like this should work

Code: [Select]
{
    use esmith::AccountsDB;
    my $adb = esmith::AccountsDB->open_ro();
    $OUT = "";

    foreach my $ibay ($adb->ibays)
    {
      my %properties = $ibay->props;
      my $key = $ibay->key;
      if ($properties{'HTTPSredir'})
      {
          if ($properties{'HTTPSredir'} eq 'on')
          {
             if ($port ne "443")
             {
                $OUT .= "    ## Redirect Web Address to Secure Address\n";
                $OUT .= "    RewriteEngine on\n";
                $OUT .= "    RewriteRule ^/$key(/.*|\$) https://%{HTTP_HOST}/$key\$1 [L,R]\n";
                $OUT .= "    ## End Of Redirect\n";
              }
          }
       }
    }
}


Slightly modified Ray's code. It should need only one 60redir-ibay custom fragment.
db accounts setprop ibayname HTTPSredir on
« Last Edit: April 27, 2011, 04:21:41 PM by johnp »

Offline mikalof

  • **
  • 27
  • +0/-0
Re: Redirect ibay to use https
« Reply #11 on: April 28, 2011, 01:51:55 PM »
This one works even better! I can see the RewriteRule is a bit different, it apparently redirects also to subdirs and files that are referenced, not only to ibay root.

Is this The RewriteRule that completely "translates" the http request to a https? At least not yet has anyone complained about old http links not working...

Offline johnp

  • *****
  • 312
  • +0/-0
Re: Redirect ibay to use https
« Reply #12 on: April 28, 2011, 08:43:12 PM »
Yes, I modified the rewrite rule yesterday morning to account for lower levels. Since writing code is not my forte, I took most if it from the 2 fragments discussed in the howto.

I believe the logic is sound and from my limited testing, I have found no problem.

Ray's code can also be used for non ibay custom-templates fragments.
« Last Edit: April 29, 2011, 03:20:55 AM by johnp »

Offline johnp

  • *****
  • 312
  • +0/-0
Re: Redirect ibay to use https
« Reply #13 on: April 29, 2011, 01:15:53 AM »
FWIW, If you want to get the same results using Ray's code, change the RewriteRule from:

Code: [Select]
RewriteRule ^/ibayname https://%{HTTP_HOST}/ibayname
to

Code: [Select]
RewriteRule ^/ibayname(/.*|$) https://%{HTTP_HOST}/ibayname$1  [L,R]

BTW, thanks for bringing this issue up as I had encounter it before but never took the time to look at it deeper as I already used Ray's code for my needs. It's nice to be able to give back to the community. :)

One other thing, I believe the current proper way to restart httpd is:

Code: [Select]
sv t httpd-e-smith

« Last Edit: April 29, 2011, 01:45:01 AM by johnp »