mod_alias equivalent for tomcat 8?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

mod_alias equivalent for tomcat 8?

Chris Cheshire-2
In tomcat8, how do I go about configuring a Resources element to
replace mod_alias directives in httpd?


Currently my mod_alias config for httpd has

    AliasMatch ^/images/(.*)$ /var/cdn/sandbox1/images/$1
    AliasMatch ^/(.*)/images/(.*)$ /var/cdn/sandbox1-$1/images/$2
    <DirectoryMatch /var/cdn/sandbox1(.*)/images>
        Order allow,deny
        Allow from all
    </DirectoryMatch>


inside a virtualhost.


Now mod_jk config is now just

    JkMount  /* sandbox1

to send everything to tomcat (I was unmounting /images otherwise to
get mod_alias to do its thing).

I have tried all kinds of variations of

  <Resources>
    <PreResources base="/var/cdn/sandbox1/images"
                  className="org.apache.catalina.webresources.DirResourceSet"
                  webAppPath="/images" />
  </Resources>


in my context.xml and I get nothing but 404s from tomcat.


What is the difference between FileResourceSet and DirResourceSet? The
documentation explains JarResourceSet and ignores the other two. Even
the javadocs don't say much that would lead to me use over the other.

I tried to configure logging by adding

org.apache.catalina.webresources.level = FINEST

to logging.properties but nothing appears in catalina.out (yes I
restarted tomcat). I am utterly clueless when it comes to juli, I've
been using log4j and logback since dinosaurs roamed the earth.

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: mod_alias equivalent for tomcat 8?

Mark Thomas-2
On 08/09/17 23:00, Chris Cheshire wrote:
> In tomcat8, how do I go about configuring a Resources element to
> replace mod_alias directives in httpd?

<snip/>

> I have tried all kinds of variations of
>
>   <Resources>
>     <PreResources base="/var/cdn/sandbox1/images"
>                   className="org.apache.catalina.webresources.DirResourceSet"
>                   webAppPath="/images" />
>   </Resources>
>
>
> in my context.xml and I get nothing but 404s from tomcat.

Check the logs for error messages. You need "webAppMount" rather than
"webAppPath". The following works for me:

<Context>
  <Resources>
    <PreResources
        className="org.apache.catalina.webresources.DirResourceSet"
             base="/mnt/server01/pictures"
      webAppMount="/pictures" />
  </Resources>
</Context>

in $CATALINA_BASE/Catalina/localhost/ROOT.xml

HTH,

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: mod_alias equivalent for tomcat 8?

Chris Cheshire-2
On Mon, Sep 11, 2017 at 9:40 AM, Mark Thomas <[hidden email]> wrote:

> On 08/09/17 23:00, Chris Cheshire wrote:
>> In tomcat8, how do I go about configuring a Resources element to
>> replace mod_alias directives in httpd?
>
> <snip/>
>
>> I have tried all kinds of variations of
>>
>>   <Resources>
>>     <PreResources base="/var/cdn/sandbox1/images"
>>                   className="org.apache.catalina.webresources.DirResourceSet"
>>                   webAppPath="/images" />
>>   </Resources>
>>
>>
>> in my context.xml and I get nothing but 404s from tomcat.
>
> Check the logs for error messages. You need "webAppMount" rather than
> "webAppPath". The following works for me:
>

/facepalm

There was nothing however in catalina.log. Fiddling around, it seems that is due
to the way apps are deployed on the fly via the manager webapp vs
tomcat restarting.

I usually deploy as an exploded directory due to needing to change configuration
before deployment (no, I don't have an ant build that sets it all up,
lack of time/resources)
and on the fly changes of JS/CSS/JSPs. (I know that isn't a good practice for a
production deployment, but it is what I have to work with)

I found ROOT.xml in conf/Catalina/${hostname} as a copy of META-INF/context.xml
BEFORE I made the changes, therefore the invalid config was never being read,
hence no errors.

I was under the impression that restarting tomcat picked up changes to
META-INF/context.xml. However it seems that if the app is deployed on the
fly with the manager webapp it copies context.xml into the conf tree,
but if the exploded
directory is present when tomcat restarts it doesn't copy the
context.xml into the conf tree.
Why doesn't tomcat copy context.xml into the conf tree if it doesn't
exist when it
deploys a webapp on startup?

Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: mod_alias equivalent for tomcat 8?

Mark Thomas-2
On 11/09/17 16:07, Chris Cheshire wrote:

> Why doesn't tomcat copy context.xml into the conf tree if it doesn't
> exist when it
> deploys a webapp on startup?

That behaviour caused problems for some users so it is configurable. See
copyXML on the Host

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]