0

I have a Plone-based site, running behind Apache 2.4, which could perform a little better. One idea is to have Apache serve the static parts of the contents, preventing them from being rewritten for the Plone process, as is commonly done:

RewriteEngine On
RewriteRule  ^/(.*) http://localhost:8080/VirtualHostBase/http/%{HTTP_HOST}:80/Plone/VirtualHostRoot/$1 [L,P

Those static contents are not all in the same place. However, Plone provides a standard way of naming resource directories; e.g., the "browser" mybrowser of myproduct could have a file system directory static:

/my/plone/root/Products/myproduct/mybrowser/static/

which would be published as /++resource++mybrowser-static.

There is no much point in having Plone serve the static files, so I'd like to prevent certain requests from being rewritten but rather served directly.

This is what I tried:

# in Plone: /++resource++mybrowser-static
<Directory /my/plone/root/Products/myproduct/mybrowser/static>
    Options All
    AllowOverride All
    Require all granted
</Directory>
Alias /static                       /my/plone/root/Products/myproduct/mybrowser/static
Alias /++resource++mybrowser-static /my/plone/root/Products/myproduct/mybrowser/static
LogLevel alert rewrite:trace3 alias:trace3
...
RewriteCond %{REQUEST_URI} !^/++resource++mybrowser-static
RewriteCond %{REQUEST_URI} !^/static/
RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/%{HTTP_HOST}:80/Plone/VirtualHostRoot/$1 [L,P]

Thus, I currently have two aliases for the same directory; the ++ version is the more general approach, so I'd like it to work.

However, when I request http://my.site.com/static/logo.png, this works:

... [rewrite:trace2] ... init rewrite engine with requested uri /static/logo.png
... [rewrite:trace3] ... applying pattern '^/(.*)' to uri '/static/logo.png'
... [rewrite:trace1] ... pass through /static/logo.png

... while the .../++resource++mybrowser-static/ version doesn't (i.e. this is served by Zope):

... [rewrite:trace2] ... init rewrite engine with requested uri /++resource++mybrowser-static/logo.png
... [rewrite:trace3] ... applying pattern '^/myunitracc([/?].+)\\?$' to uri '/++resource++mybrowser-static/logo.png'
... [rewrite:trace3] ... applying pattern '^/(.*)' to uri '/++resource++mybrowser-static/logo.png'
... [rewrite:trace2] ... rewrite '/++resource++mybrowser-static/logo.png' -> 'http://localhost:8080/VirtualHostBase/http/my.site.com:80/Plone/VirtualHostRoot/++resource++mybrowser-static/logo.png'
... [rewrite:trace2] ... forcing proxy-throughput with http://localhost:8080/VirtualHostBase/http/my.site.com:80/Plone/VirtualHostRoot/++resource++mybrowser-static/logo.png
... [rewrite:trace1] ... go-ahead with proxy request proxy:http://localhost:8080/VirtualHostBase/http/my.site.com:80/Plone/VirtualHostRoot/++resource++mybrowser-static/logo.png [OK]

I'd like to have pass through instead of forcing proxy-throughput in both cases.

Do I need to quote the + characters somehow? I already tried to prefix them all by backslashes, or replace them by %2B, but it didn't seem to make any difference.

I had a look here as well, but ProxyPass <url> ! didn't work for me (yet?), maybe because of the RewriteRule instead of ProxyPass / ProxypassReverse (the Zope virtual host machinery takes care of the "reverse" part itself).

Thanks for any help!

Tobias
  • 165
  • 1
  • 9

1 Answers1

1

I found a way to make it work.

After increasing the log level:

LogLevel alert rewrite:trace5

... I got some additional info about the matching of patterns (at level 4).

When put in square brackets, the literal + characters work:

RewriteCond !^/[+][+]resource[+][+]myproduct-static/
RewriteRule ...    

For the alias, this is not necessary:

Alias /++resource++myproduct-static /my/zope/root/Products/myproduct/static
Tobias
  • 165
  • 1
  • 9