You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nikolay Diulgerov <nd...@imx.fr> on 2009/07/29 13:15:58 UTC

tomcat and apache document root

hello there,
I just wonder if there is an option to configure apache to serve as 
document root /tomcat/webapps/myapp

I have in apache



DocumentRoot "/tomcat/webapps/myapp"
<Directory "/tomcat/webapps/myapp">
    Options FollowSymlinks
    DirectoryIndex index.jsp
    AllowOverride None
    Allow from all

</Directory>

JkMount /*.jsp ajp13
JkMount /*.jspa ajp13
JkMount /* ajp13


But seems mod_jk redirects to tomcat / which is the default tomcat login 
page.
I know that I can change the root of tomcat server to point to 
webapps/myapp and then the config above will work
and when I access tomcat on 8080 to see myapp instead of the tomcat 
default page

but I wonder if there is an option to do this on apache level probably 
playing with mod_jk


-- 
Best regards,

Nikolay Diulgerov



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


Re: tomcat and apache document root

Posted by Mark Thomas <ma...@apache.org>.
Nikolay Diulgerov wrote:
> Mark,
> what do you mean by
> separation of httpd and Tomcat

I mean that my own view is that httpd and Tomcat should not be serving
content from the same directory structure. That way only Tomcat can
possibly serve the files Tomcat is meant to serve and only httpd can
serve the files httpd is meant to serve. If you get your configuration
wrong the worst that will happen is a 404.

If Tomcat and httpd serve files from the same directory structure and
you get your configuration wrong the worst that can happen is that files
that are never meant to be accessible are readable to anyone with a browser.

Mark

> 
> Do you mean that httpd should redirect all requests to tomcat and not
> serve static files?
> Or that httpd should have alias /myapp
> and still serve static files for it.
> Or something different? 
> 
> 
> 
> Mark Thomas wrote:
>> Nikolay Diulgerov wrote:
>>  
>>> I wonder then if I can use in server.xml
>>> <Context path="" docBase="/tomcat/webapps/myapp"/>
>>> To change the default application serving when someone requests
>>> myserver.com:8080
>>>     
>>
>> No. That will result in double deployment. Just rename webapps/myapp to
>> webapps/ROOT
>>
>>  
>>> And then in apache to use
>>>
>>> DocumentRoot "/tomcat/webapps/myapp"
>>>     
>> Make this:
>> DocumentRoot "/tomcat/webapps/ROOT"
>> and also below.
>>
>>  
>>> <Directory "/tomcat/webapps/myapp">
>>>    Options FollowSymlinks
>>>    DirectoryIndex index.html login.jsp
>>>    AllowOverride None
>>>    Allow from all
>>> </Directory>
>>>    <Directory "/tomcat/webapps/myapp/WEB-INF/">
>>>    AllowOverride None
>>>    deny from all
>>> </Directory>
>>>    <Directory "/tomcat/webapps/myapp/META-INF/">
>>>    AllowOverride None
>>>    deny from all
>>> </Directory>
>>>     
>> Better. Depending on settings JSP source code disclosure may still be an
>> issue. (ie requests for index.jSp may get served by httpd as static
>> files).
>>
>>  
>>> JkMount /*.jsp client
>>> JkMount /*.do client
>>>     
>>
>>
>> I always recommend separation of httpd and Tomcat but if you are going
>> to have them serving from the same directory structure then you are
>> heading in the right direction.
>>
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>   
> 




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


Re: tomcat and apache document root

Posted by Mark Thomas <ma...@apache.org>.
Nikolay Diulgerov wrote:
> About the double deployment ... you seems to be right
Odd that...

> but if I dont want
> to rename the app to ROOT can I move it to for example
> /myapp
> and then to have
> <Context path="" docBase="/myapp"/>

Yes. If the docBase is outside of the Host's appBase then you can do that.

> And second ... is there an option to change so not
> /tomcat/webapps/ROOT is the default but
> /tomcat/webapps/myapp is the default.

No.

Mark



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


Re: tomcat and apache document root

Posted by Nikolay Diulgerov <nd...@imx.fr>.
About the double deployment ... you seems to be right but if I dont want 
to rename the app to ROOT can I move it to for example
/myapp
and then to have
<Context path="" docBase="/myapp"/>

And second ... is there an option to change so not
/tomcat/webapps/ROOT is the default but
/tomcat/webapps/myapp is the default.







Nikolay Diulgerov wrote:
> Mark,
> what do you mean by
> separation of httpd and Tomcat
>
> Do you mean that httpd should redirect all requests to tomcat and not 
> serve static files?
> Or that httpd should have alias /myapp
> and still serve static files for it.
> Or something different? 
>
>
>
> Mark Thomas wrote:
>> Nikolay Diulgerov wrote:
>>  
>>> I wonder then if I can use in server.xml
>>> <Context path="" docBase="/tomcat/webapps/myapp"/>
>>> To change the default application serving when someone requests
>>> myserver.com:8080
>>>     
>>
>> No. That will result in double deployment. Just rename webapps/myapp to
>> webapps/ROOT
>>
>>  
>>> And then in apache to use
>>>
>>> DocumentRoot "/tomcat/webapps/myapp"
>>>     
>> Make this:
>> DocumentRoot "/tomcat/webapps/ROOT"
>> and also below.
>>
>>  
>>> <Directory "/tomcat/webapps/myapp">
>>>    Options FollowSymlinks
>>>    DirectoryIndex index.html login.jsp
>>>    AllowOverride None
>>>    Allow from all
>>> </Directory>
>>>    <Directory "/tomcat/webapps/myapp/WEB-INF/">
>>>    AllowOverride None
>>>    deny from all
>>> </Directory>
>>>    <Directory "/tomcat/webapps/myapp/META-INF/">
>>>    AllowOverride None
>>>    deny from all
>>> </Directory>
>>>     
>> Better. Depending on settings JSP source code disclosure may still be an
>> issue. (ie requests for index.jSp may get served by httpd as static 
>> files).
>>
>>  
>>> JkMount /*.jsp client
>>> JkMount /*.do client
>>>     
>>
>>
>> I always recommend separation of httpd and Tomcat but if you are going
>> to have them serving from the same directory structure then you are
>> heading in the right direction.
>>
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>   
>

-- 
Best regards,

Nikolay Diulgerov
Network Administrator
E-mail: ndiulgerov@imx.fr
Telephone : +33 4 89 87 77 77
Fax :       +33 4 89 87 77 00
Web: http://www.codix-france.com


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


Re: tomcat and apache document root

Posted by Nikolay Diulgerov <nd...@imx.fr>.
Mark,
what do you mean by 

separation of httpd and Tomcat

Do you mean that httpd should redirect all requests to tomcat and not 
serve static files?
Or that httpd should have alias /myapp
and still serve static files for it.
Or something different?  




Mark Thomas wrote:
> Nikolay Diulgerov wrote:
>   
>> I wonder then if I can use in server.xml
>> <Context path="" docBase="/tomcat/webapps/myapp"/>
>> To change the default application serving when someone requests
>> myserver.com:8080
>>     
>
> No. That will result in double deployment. Just rename webapps/myapp to
> webapps/ROOT
>
>   
>> And then in apache to use
>>
>> DocumentRoot "/tomcat/webapps/myapp"
>>     
> Make this:
> DocumentRoot "/tomcat/webapps/ROOT"
> and also below.
>
>   
>> <Directory "/tomcat/webapps/myapp">
>>    Options FollowSymlinks
>>    DirectoryIndex index.html login.jsp
>>    AllowOverride None
>>    Allow from all
>> </Directory>
>>    <Directory "/tomcat/webapps/myapp/WEB-INF/">
>>    AllowOverride None
>>    deny from all
>> </Directory>
>>    <Directory "/tomcat/webapps/myapp/META-INF/">
>>    AllowOverride None
>>    deny from all
>> </Directory>
>>     
> Better. Depending on settings JSP source code disclosure may still be an
> issue. (ie requests for index.jSp may get served by httpd as static files).
>
>   
>> JkMount /*.jsp client
>> JkMount /*.do client
>>     
>
>
> I always recommend separation of httpd and Tomcat but if you are going
> to have them serving from the same directory structure then you are
> heading in the right direction.
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   

-- 
Best regards,

Nikolay Diulgerov
Network Administrator
E-mail: ndiulgerov@imx.fr
Telephone : +33 4 89 87 77 77
Fax :       +33 4 89 87 77 00
Web: http://www.codix-france.com


Re: tomcat and apache document root

Posted by Mark Thomas <ma...@apache.org>.
Nikolay Diulgerov wrote:
> I wonder then if I can use in server.xml
> <Context path="" docBase="/tomcat/webapps/myapp"/>
> To change the default application serving when someone requests
> myserver.com:8080

No. That will result in double deployment. Just rename webapps/myapp to
webapps/ROOT

> And then in apache to use
> 
> DocumentRoot "/tomcat/webapps/myapp"
Make this:
DocumentRoot "/tomcat/webapps/ROOT"
and also below.

> <Directory "/tomcat/webapps/myapp">
>    Options FollowSymlinks
>    DirectoryIndex index.html login.jsp
>    AllowOverride None
>    Allow from all
> </Directory>
>    <Directory "/tomcat/webapps/myapp/WEB-INF/">
>    AllowOverride None
>    deny from all
> </Directory>
>    <Directory "/tomcat/webapps/myapp/META-INF/">
>    AllowOverride None
>    deny from all
> </Directory>
Better. Depending on settings JSP source code disclosure may still be an
issue. (ie requests for index.jSp may get served by httpd as static files).

> JkMount /*.jsp client
> JkMount /*.do client


I always recommend separation of httpd and Tomcat but if you are going
to have them serving from the same directory structure then you are
heading in the right direction.

Mark


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


Re: tomcat and apache document root

Posted by Nikolay Diulgerov <nd...@imx.fr>.
I wonder then if I can use in server.xml
<Context path="" docBase="/tomcat/webapps/myapp"/>
To change the default application serving when someone requests 
myserver.com:8080

And then in apache to use

DocumentRoot "/tomcat/webapps/myapp"

<Directory "/tomcat/webapps/myapp">
    Options FollowSymlinks
    DirectoryIndex index.html login.jsp
    AllowOverride None
    Allow from all
</Directory>
    <Directory "/tomcat/webapps/myapp/WEB-INF/">
    AllowOverride None
    deny from all
</Directory>
    <Directory "/tomcat/webapps/myapp/META-INF/">
    AllowOverride None
    deny from all
</Directory>
JkMount /*.jsp client
JkMount /*.do client







Mark Thomas wrote:
> Nikolay Diulgerov wrote:
>   
>> hello there,
>> I just wonder if there is an option to configure apache to serve as
>> document root /tomcat/webapps/myapp
>>     
>
> Unless you are very careful (and you haven't been - /WEB-INF/ &
> /META-INF/ are wide open), that is a really bad idea from a security
> point of view. It is much better to keep Tomcat and httpd separate.
>
>
>   
>> JkMount /*.jsp ajp13
>> JkMount /*.jspa ajp13
>> JkMount /* ajp13
>>     
>
> Use
> JkMount /myapp/*.jsp ajp13
>
> etc to map a single context.
>
> Mark
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   

-- 
Best regards,

Nikolay Diulgerov
Network Administrator
E-mail: ndiulgerov@imx.fr
Telephone : +33 4 89 87 77 77
Fax :       +33 4 89 87 77 00
Web: http://www.codix-france.com


Re: tomcat and apache document root

Posted by Mark Thomas <ma...@apache.org>.
Nikolay Diulgerov wrote:
> hello there,
> I just wonder if there is an option to configure apache to serve as
> document root /tomcat/webapps/myapp

Unless you are very careful (and you haven't been - /WEB-INF/ &
/META-INF/ are wide open), that is a really bad idea from a security
point of view. It is much better to keep Tomcat and httpd separate.


> JkMount /*.jsp ajp13
> JkMount /*.jspa ajp13
> JkMount /* ajp13

Use
JkMount /myapp/*.jsp ajp13

etc to map a single context.

Mark




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