Script handler enhancement

22 views
Skip to first unread message

Domingo Alvarez Duarte

unread,
Apr 8, 2015, 12:25:42 PM4/8/15
to openlitespee...@googlegroups.com
Hello !

Starting with openlitespeed I think that script handler (and related context) can be enhanced by having an option to choose between suffix/prefix and also an option to replace the prefix/suffix.

With that we can have script handlers/context like:

- With suffix: "php" replaced by "lua" and handled by mod_lua (supposing that it'll make sense).
- With prefix: "/lua/" replaced by "/" and handled by mod_lua.
- With prefix: "/db/" replaced by "/" and handled by one external application "web server".
...

I'm looking to try implement and started diving in the code, anyone here with more experience/knowledge on openlitespeed code can point where I should look for to implement this (*.h *.cpp *.php) ?

Cheers !

George Wang

unread,
Apr 8, 2015, 1:52:55 PM4/8/15
to openlitespee...@googlegroups.com
Hi,

Thanks for the proposal.
What you want to accomplished, can be done through configurations
combination of suffix handler, context and URL rewrite, those pieces are
already there.

URL rewrite is intended for URL and suffix modification. and our rewrite
engine is pretty much compatible with Apache's.

A dedicate feature may have slight speed advantage, but I am not sure
the effort can be justified or not.

Best regards,
George Wang
> --
> You received this message because you are subscribed to the Google
> Groups "OpenLiteSpeed Development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to openlitespeed-deve...@googlegroups.com
> <mailto:openlitespeed-deve...@googlegroups.com>.
> To post to this group, send email to
> openlitespee...@googlegroups.com
> <mailto:openlitespee...@googlegroups.com>.
> Visit this group at
> http://groups.google.com/group/openlitespeed-development.
> For more options, visit https://groups.google.com/d/optout.

Domingo Alvarez Duarte

unread,
Apr 9, 2015, 3:29:54 PM4/9/15
to openlitespee...@googlegroups.com
Thanks for the advice !

I decided to go straight way to the configuration first but it seems that I'm missing something here:

------
context /nginx/ {
  type                    proxy
  handler                 nginx
  addDefaultCharset       off
 
    rewrite  {
      enable                  1
      logLevel                9

      rules                   <<<END_rules
        RewriteRule ^/nginx/(.*)$    /$1 [L]
      END_rules

    } 
}
------

It seems that the rewrite rule is ignored inside "context", is this a bug ?

Cheers !

George Wang

unread,
Apr 9, 2015, 3:38:49 PM4/9/15
to openlitespee...@googlegroups.com
Hi,

Our rewrite engine follows Apache's rewrite specification, in a context
(Apache Location/Directory equivalent), rewrite base will be chopped off
the URL, so you should use

RewriteRule ^(.*)$ /$1 [L]

instead.
You can use your original rule at vhost level rewrite. The full URL is
evaluated against rewrite rules.

Turn on rewrite logging to find out what happens.

Best regards,
George Wang

Domingo Alvarez Duarte

unread,
Apr 9, 2015, 5:32:22 PM4/9/15
to openlitespee...@googlegroups.com
Thanks for the advice !

But it doesn't work the way I expect, it seems that on "HttpReq::processContext()" there is a check for HandlerType::HT_PROXY and return a value that makes it skip the context rewrite rules.

int HttpReq::processContext()
{
...
    if (m_pHttpHandler->getHandlerType() == HandlerType::HT_PROXY)
        return -2;
Reply all
Reply to author
Forward
0 new messages