Context with "exp: ..." URI don't seem to work

#1
Hello,

I have a FastCGI application running on URI / of a virtualhost. I would like web requests of files (which are named like *.*) not to be routed to this FastCGI application so I have set two contexts for this virtual host in the following sequence order :

1) Static :
URI = exp:(.+\.[^\/]+)$
Location = $DOC_ROOT/$1
Accessible = Yes

2) FastCGI : a working context with URI = /

I reloaded and even restarted LSWS with no success : every time I try to access a file on this virtual host (for example : /css/style.css which exists and is accessible without the context of sequence 2) the request is routed to the FastCGI app.

When I set URI ="/css/" with location = $DOC_ROOT/css/ in the URI of the context #1, I can view my /css/style.css => is "exp:..." in URIs not working ?
What is wrong ? How to achieve my goal ?

Thank you for answers.
 

mistwang

LiteSpeed Staff
#2
That's normal, as LSWS now only process matching context when there is no explicit direct match. So, in your case, the matching context has no effect. Normal contexts have high priority than matching contexts.

With current release, you have to use normal contexts for those files like /css/ you tried.

There is another possible work around by avoiding using FastCGI Context '/' which will match any request, instead, define a Matching FastCGI context with URI "exp:^/$" to match only request to '/' and other FastCGI contexts for each unique URI that should be processed by the FCGI.
But, there is a bug with FastCGI Matching Context in current release that will be fixed. So you have to wait till next release to be able to do that.
 
#3
Thank you for the answer mistwang.

In the next version, can you make an an option to let normal contexts have the same priority as matching contexts on a per-vhost basis, or something like that, please ?

I will wait for the next version anyway.

Thanks,
Roman.
 
#7
Hello mistwang. It works with 2.1.5 ! Thank you again :D.

There is a small bug now : I tried a context Static exp:^/((images|javascript)\/.+)$
Although it appears correctly in my contexts list, when I try to view or edit it, all the rows of the table or the forum are empty.

However, a FastCGI context with URI / is viewable and editable.

Also, when I try to delete this context, I click "yes" to confirm and I am then redirected to an empty contexts list. When I click the "Context" tab I see the list back.

Here is the generated context part of the vhost conf :
Code:
<contextList>
    <context>
      <type>NULL</type>
      <uri>exp:^/((images|javascript)\/.+)$</uri>
      <location>$DOC_ROOT/$1</location>
      <allowBrowse>1</allowBrowse>
      <accessControl>
      </accessControl>
      <addDefaultCharset>off</addDefaultCharset>
      <rewrite>
      </rewrite>
    </context>
    <context>
      <type>fcgi</type>
      <uri>/</uri>
      <handler>Test fcgi</handler>
      <accessControl>
      </accessControl>
      <addDefaultCharset>off</addDefaultCharset>
    </context>
</contextList>
 

mistwang

LiteSpeed Staff
#8
Thank you for the update.
The new bug should be fixed in the final 2.1.5 package.
For that kind of context, it is better to use two plain context instead of one matching context, should be more efficient. :)
 
Top