You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Nicolas Daniels <ni...@swing.be> on 2013/02/18 12:54:20 UTC

[users@httpd] Re: Apache 2.4: Mod Cache: authorization required

Hello,

Ok I figured out how to allow caching for authenticated urls: adding 
"Cache-Control" header with public option do the trick.

Now I still have the problem that the cache key is built upon the url 
BEFORE the rewrite occurs.

Is it possible to change this behavior ?

I tried with

AddOutputFilterByType  REWRITE;CACHE  text/html

But rewrite is not a filter (or I don't have the appropriate name).

Thanks,

Nicolas


On 14/02/2013 16:41, Nicolas Daniels wrote:
> Hi all,
>
> I'm trying hard to configure mod_cache with mod_cache_disk and apache 
> 2.4, without real success.
>
> I'm able to enable cache for public files (no authentication), but not 
> for private ones. From my understanding, setting |CacheQuickHandler to 
> off |should have done the trick, but it keeps complaining in the logs:
>
> [Thu Feb 14 15:20:18.997941 2013] [cache:debug] [pid 18018:tid 
> 140317277726464] mod_cache.c(1073): [client xxxxxxxx] AH00768: cache: 
> /file/files/test.txt not cached. Reason: Authorization required
>
> Looking around for a solution to this problem, I found also another 
> one: cache key is computed before rewrite rule applies, which will 
> lead to issues as I'm rewriting the logged use in the url.
>
> My config (part of):
>
> <DirectoryMatch "^/vsite/file/.*$">
> AuthType Digest
> AuthName "bla"
> # To cache credentials, put socache ahead of dbd here
> AuthDigestProvider socache dbd
> # Also required for caching: tell the cache to cache dbd lookups!
> AuthnCacheProvideFor dbd
> AuthnCacheContext blabla
>
> Require valid-user
> AuthDBDUserRealmQuery "SELECT digestpwd FROM user WHERE name= %s"
> </DirectoryMatch>
>
> RewriteCond %{REQUEST_METHOD} GET
> RewriteCond %{LA-U:REMOTE_USER} ([0-9]+)
> RewriteRule ^/file/(.*) /data/%1/$1 [L]
>
> <IfModule mod_cache.c>
> <IfModule mod_cache_disk.c>
> LogLevel cache:trace8
> CacheQuickHandler off
> CacheRoot /tmp/apachecache
> CacheEnable disk /
> CacheDefaultExpire 120
> CacheIgnoreURLSessionIdentifiers jsessionid JSESSIONID
> </IfModule>
> </IfModule>
>
> Any way to get around those problems ?
>
> Thanks a lot for your help !
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Re: Apache 2.4: Mod Cache: authorization required

Posted by Nicolas Daniels <ni...@swing.be>.
Hi,

 > Isnt it what CacheStorePrivate is for?

I tried with this option only, it doesn't work. Seems correct as the 
docs says:

"Ordinarily, responses with Cache-Control: private header values will 
not be stored in the cache. The |CacheStorePrivate| directive allows 
this behavior to be overridden. |CacheStorePrivate| On tells the server 
to attempt to cache the resource even if it contains private header 
values. Resources requiring authorization will /never/ be cached."

Notice the " Resources requiring authorization will /never/ be cached."

Anyway it works with Cache-Control: public.

I also found a solution for my other problem: cache key computed before 
rewrite. Adding a [PT] to the rewrite rule do the trick !

Thanks !

On 21/02/2013 08:37, Igor Cicimov wrote:
>
>
> On 18/02/2013 10:55 PM, "Nicolas Daniels" <nicolas.daniels@swing.be 
> <ma...@swing.be>> wrote:
> >
> > Hello,
> >
> > Ok I figured out how to allow caching for authenticated urls: adding 
> "Cache-Control" header with public option do the trick.
> >
> Isnt it what CacheStorePrivate is for?
>
> > Now I still have the problem that the cache key is built upon the 
> url BEFORE the rewrite occurs.
> >
> > Is it possible to change this behavior ?
> >
> > I tried with
> >
> > AddOutputFilterByType  REWRITE;CACHE  text/html
> >
> > But rewrite is not a filter (or I don't have the appropriate name).
> >
> > Thanks,
> >
> > Nicolas
> >
> >
> >
> > On 14/02/2013 16:41, Nicolas Daniels wrote:
> >>
> >> Hi all,
> >>
> >> I'm trying hard to configure mod_cache with mod_cache_disk and 
> apache 2.4, without real success.
> >>
> >> I'm able to enable cache for public files (no authentication), but 
> not for private ones. From my understanding, setting 
> |CacheQuickHandler to off |should have done the trick, but it keeps 
> complaining in the logs:
> >>
> >> [Thu Feb 14 15:20:18.997941 2013] [cache:debug] [pid 18018:tid 
> 140317277726464] mod_cache.c(1073): [client xxxxxxxx] AH00768: cache: 
> /file/files/test.txt not cached. Reason: Authorization required
> >>
> >> Looking around for a solution to this problem, I found also another 
> one: cache key is computed before rewrite rule applies, which will 
> lead to issues as I'm rewriting the logged use in the url.
> >>
> >> My config (part of):
> >>
> >> <DirectoryMatch "^/vsite/file/.*$">
> >> AuthType Digest
> >> AuthName "bla"
> >> # To cache credentials, put socache ahead of dbd here
> >> AuthDigestProvider socache dbd
> >> # Also required for caching: tell the cache to cache dbd lookups!
> >> AuthnCacheProvideFor dbd
> >> AuthnCacheContext blabla
> >>
> >> Require valid-user
> >> AuthDBDUserRealmQuery "SELECT digestpwd FROM user WHERE name= %s"
> >> </DirectoryMatch>
> >>
> >> RewriteCond %{REQUEST_METHOD} GET
> >> RewriteCond %{LA-U:REMOTE_USER} ([0-9]+)
> >> RewriteRule ^/file/(.*) /data/%1/$1 [L]
> >>
> >> <IfModule mod_cache.c>
> >> <IfModule mod_cache_disk.c>
> >> LogLevel cache:trace8
> >> CacheQuickHandler off
> >> CacheRoot /tmp/apachecache
> >> CacheEnable disk /
> >> CacheDefaultExpire 120
> >> CacheIgnoreURLSessionIdentifiers jsessionid JSESSIONID
> >> </IfModule>
> >> </IfModule>
> >>
> >> Any way to get around those problems ?
> >>
> >> Thanks a lot for your help !
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org 
> <ma...@httpd.apache.org>
> > For additional commands, e-mail: users-help@httpd.apache.org 
> <ma...@httpd.apache.org>
> >
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Re: Apache 2.4: Mod Cache: authorization required

Posted by Igor Cicimov <ic...@gmail.com>.
On 18/02/2013 10:55 PM, "Nicolas Daniels" <ni...@swing.be> wrote:
>
> Hello,
>
> Ok I figured out how to allow caching for authenticated urls: adding
"Cache-Control" header with public option do the trick.
>
Isnt it what CacheStorePrivate is for?

> Now I still have the problem that the cache key is built upon the url
BEFORE the rewrite occurs.
>
> Is it possible to change this behavior ?
>
> I tried with
>
> AddOutputFilterByType  REWRITE;CACHE  text/html
>
> But rewrite is not a filter (or I don't have the appropriate name).
>
> Thanks,
>
> Nicolas
>
>
>
> On 14/02/2013 16:41, Nicolas Daniels wrote:
>>
>> Hi all,
>>
>> I'm trying hard to configure mod_cache with mod_cache_disk and apache
2.4, without real success.
>>
>> I'm able to enable cache for public files (no authentication), but not
for private ones. From my understanding, setting |CacheQuickHandler to off
|should have done the trick, but it keeps complaining in the logs:
>>
>> [Thu Feb 14 15:20:18.997941 2013] [cache:debug] [pid 18018:tid
140317277726464] mod_cache.c(1073): [client xxxxxxxx] AH00768: cache:
/file/files/test.txt not cached. Reason: Authorization required
>>
>> Looking around for a solution to this problem, I found also another one:
cache key is computed before rewrite rule applies, which will lead to
issues as I'm rewriting the logged use in the url.
>>
>> My config (part of):
>>
>> <DirectoryMatch "^/vsite/file/.*$">
>> AuthType Digest
>> AuthName "bla"
>> # To cache credentials, put socache ahead of dbd here
>> AuthDigestProvider socache dbd
>> # Also required for caching: tell the cache to cache dbd lookups!
>> AuthnCacheProvideFor dbd
>> AuthnCacheContext blabla
>>
>> Require valid-user
>> AuthDBDUserRealmQuery "SELECT digestpwd FROM user WHERE name= %s"
>> </DirectoryMatch>
>>
>> RewriteCond %{REQUEST_METHOD} GET
>> RewriteCond %{LA-U:REMOTE_USER} ([0-9]+)
>> RewriteRule ^/file/(.*) /data/%1/$1 [L]
>>
>> <IfModule mod_cache.c>
>> <IfModule mod_cache_disk.c>
>> LogLevel cache:trace8
>> CacheQuickHandler off
>> CacheRoot /tmp/apachecache
>> CacheEnable disk /
>> CacheDefaultExpire 120
>> CacheIgnoreURLSessionIdentifiers jsessionid JSESSIONID
>> </IfModule>
>> </IfModule>
>>
>> Any way to get around those problems ?
>>
>> Thanks a lot for your help !
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>