You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tapajyoti Roybarman <ta...@tcs.com> on 2013/12/04 13:19:41 UTC

Need Information regarding Apache Webserver static file configuration

Hi,

Could you please let me know that how can I serve static content like 
image files, css files through Apache Webserver instead of Tomcat? Please 
let me know about all the required configurations in detail. I am 
connecting Apache webserver and Tomcat using mod_proxy_http module. Also, 
please find below some information that you may require.

Apache Webserber Version  - 2.2.25

Apache Tomcat Version - 7.0.27

OS - Windows 7

Thanks in advance,

Best Regards,

Tapajyoti Roy Barman
Ph:- +919433040094
Mailto: tapajyoti.roybarman@tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you



Re: [OT] Need Information regarding Apache Webserver static file configuration

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 12/4/13, 8:14 AM, André Warnier wrote:
> It reminds me a bit of the story about a sculptor, who was aked how
> he sculpted a horse from a big block of stone.  He answered that it
> was very easy : you just remove from the stone everything that is
> not a horse.

Note that this story isn't just about any old sculptor. It was
Micha-effin-angelo.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSn2uaAAoJEBzwKT+lPKRYSnsQAIzDwGPowCxbr53FZWgkus+3
M9yWey9TYVcqlgC5MNu1LlPFftnSuNvGaF8ak4m/4kEMmFLvvp0fRmtNybGbPNF0
d/RUge0VIJ2n8nPu+Aj1oH+0y74ueGGrzyIIHLW3PbkM5mUFyl3wPZkBnbVJgNo7
QQ0UQmh51DuzlOuTMjRhzZJ04ACbctlzaW+eNe/2FoilBiwClsMll0C/iIbkDXeO
tWen9KltjbyMvT+obHMWXRcE+8fo0JgEi1MlveDEaqqVjjjehxlzkh8sBJV6NOIX
LeKBD8Qj9omV84conwUxeMk/h8HNQ4WOkXjsiiH8kPWOD4/OTyc9cba4a9saP/EI
RYR/43nkukLa88wotMHI8AvTtqJokdQH17k1JnLqL0Ivr3ZLP2B/emam4IHk9jrf
sOXFrmr1WX1Gp5D3i9PERYbf8P/VsS7qQ9e2s5c4bMNi2R/2mTrJJveM61HWNy9B
GILxtS9jYYkrXsXfviSMYPiweozfGRDzZAID+jL1CgR8OYM7qWBsvmEAq37As/EV
jSbBOOl5YQni0BPfB0rzBeEwYnCjesn8yrR/14QAfMfIHzaMLyStgV7lwESdCH70
lahDSjmRa4BaJlDm91zyRcQuV/oKcQSdCjUCdlT1/f3oH4Zi+R+iymeTGTkH8VV5
5t2yqXMb+7w2RFMv8mZ3
=h6m3
-----END PGP SIGNATURE-----

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


Re: Need Information regarding Apache Webserver static file configuration

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

David,

On 12/5/13, 1:33 PM, David kerber wrote:
> On 12/5/2013 5:37 AM, Tapajyoti Roybarman wrote:
>> Hi Andre,
>> 
>> I apologize for not following the mailing rule. Actually this is
>> the first time that I am taking the help of such a forum.
>> 
>> Before I begin asking you anything I want to thank you for such
>> a detailed explanation.
>> 
>> To begin with, answer to your question - "why do you want to
>> serve these files from Apache httpd, instead of letting Tomcat do
>> it?" I am planning to use Apache httpd as a Load Balancer. And to
>> improve the performance of my application, I want to serve the
>> static content from apache itself.
> 
> Keep in mind that the performance boost you get from having httpd 
> serving static files instead of Tomcat will be small, perhaps not
> even measurable depending on the details of your configuration and
> application.
> 
> Having httpd as a load balancer is a good use of it, but having it
> serve all your static files as a performance booster, not so much.

Well, given that he's going to use httpd for load-balancing, I can't
imagine that proxying all the static content will be as fast as
duplicating that content out to the httpd instance. I'm willing to bet
there is a measurable difference.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSoM9PAAoJEBzwKT+lPKRYdMwQAJ1b5s9YvC23X4tz/X1nIbRV
jXGMgJFLyx1j1CLu5rgv5ARmltpQJw604/2XgwXDudwW/7fXmeBczJcX7DH2ZqdO
ll0f/ruuHJGkGHAX33LbiyeeIgR/M0eyQEhEYO4xaHFcMxkUHllA247b5+b9/Bgc
cWPhhCo6fQx+pwU5himPeqXYQdvo+1R3uhjTe15V88VnptV+AEWFf75xPDjxJNtY
5pF4+HuKimOLEQj0/hwFW51u4mN7+ThvWEBg+619lp4G2omzA1ZOmALGC+3ZNAh/
9zt1MCy43ENWU0lh/NNxFf9o3wKJp9j0sy60VVaBLJqmh8BXkca1sM2Bx32vA/TR
t1rExcNsif2PzHkEcWsf0IuRhONsP8xAqq5MJh08LjdL4owkht1/NdFQYO74cuFe
RS9ypl+K+cRHhZB5V6obkRgekdfnln/nLpkzxHYpwq1Pk4c8N9Rclo0zJgbAEZuM
wXvdNvb+Uy48nUalXlm3ekLfR0x1RlrMDdd14R19lG4IzfFvnwWm6xNc4N04OMfj
GgKCjNTVpaO5oXV94TsUldMWBKC3txF+Gc/C/D/QUAfayTTCYV+vNy4h1rYhR6u/
j4O4a+npHXpVqiDGT5rt4hyP/NtKVv1VYpVLxDJPcATOjPIkaZNYrfB+nw0fIj+M
yGacb91XLmnZpPDZom+P
=kkwR
-----END PGP SIGNATURE-----

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


Re: Need Information regarding Apache Webserver static file configuration

Posted by David kerber <dc...@verizon.net>.
On 12/5/2013 5:37 AM, Tapajyoti Roybarman wrote:
> Hi Andre,
>
> I apologize for not following the mailing rule. Actually this is the first
> time that I am taking the help of such a forum.
>
> Before I begin asking you anything I want to thank you for such a detailed
> explanation.
>
> To begin with, answer to your question - "why do you want to serve these
> files from Apache httpd, instead of letting Tomcat do it?" I am planning
> to use Apache httpd as a Load Balancer. And to improve the performance of
> my application, I want to serve the static content from apache itself.

Keep in mind that the performance boost you get from having httpd 
serving static files instead of Tomcat will be small, perhaps not even 
measurable depending on the details of your configuration and application.

Having httpd as a load balancer is a good use of it, but having it serve 
all your static files as a performance booster, not so much.

Dave


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


Re: How to update a web app without uploading the WAR

Posted by David kerber <dc...@verizon.net>.
On 1/21/2014 1:55 PM, James H. H. Lampert wrote:
> On 1/21/14 9:59 AM, David kerber wrote:
>> You can update the single .jsp on the server, in at least some
>> situations.  I do that occasionally when I need to get an update out and
>> can't take the service down.
>
> But note that if and when you DO replace the WAR file, it will stomp on
> whatever changes you've made in the context.

Yes, but in my use case that's ok.  I replace the .jsp first, and then 
when I can stop the service I replace the entire .war file, which will 
include the new .jsp.


>
> --
> JHHL
> (speaking from bitter experience)

Yup, me too, when I once forgot to push the updated .jsp into the new 
.war file.  Never happened again, though.


>
>
> ---------------------------------------------------------------------
> 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: How to update a web app without uploading the WAR

Posted by Hassan Schroeder <ha...@gmail.com>.
On Tue, Jan 21, 2014 at 11:14 AM, Chris Patterson <to...@vittox.com> wrote:

> Indeed, not all replacements had a good experience with some specific files.
>
> Do you know if there is some plugin for Eclipse that helps to do updates or
> sync
> just for the last changes done, or only just for one single file to be
> replaced,
> together with its associated files for successfull micro updates ?

I would seriously reconsider a deployment strategy that packs lots
of large static resources (images, PDFs) along with code.

Being able to just do a standard deploy regardless of the scope of
changes makes for a lot less mental overhead :-)

FWIW,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

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


Re: How to update a web app without uploading the WAR

Posted by Chris Patterson <to...@vittox.com>.
Thanks for your suggestions, I will try this last one.

Indeed, not all replacements had a good experience with some specific files.

Do you know if there is some plugin for Eclipse that helps to do updates 
or sync
just for the last changes done, or only just for one single file to be 
replaced,
together with its associated files for successfull micro updates ?

Dreamweaver has a facility to upload a single file for replacement and 
asks if associated
files should also be uploaded. Remote connection is previosly configured 
and tested.
I just couldn't find something similar.

Chris

El 21/01/2014 02:03 p.m., Daniel Mikusa escribió:
> On Jan 21, 2014, at 1:55 PM, James H. H. Lampert <ja...@touchtonecorp.com> wrote:
>
>> On 1/21/14 9:59 AM, David kerber wrote:
>>> You can update the single .jsp on the server, in at least some
>>> situations.  I do that occasionally when I need to get an update out and
>>> can't take the service down.
>> But note that if and when you DO replace the WAR file, it will stomp on whatever changes you've made in the context.
>>
> You can get around this if you deploy from an exploded WAR directory instead of a WAR file.  As an example, the manager application does this.
>
> Dan
>
>> ---------------------------------------------------------------------
>> 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
>
>


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


Re: How to update a web app without uploading the WAR

Posted by Daniel Mikusa <dm...@gopivotal.com>.
On Jan 21, 2014, at 1:55 PM, James H. H. Lampert <ja...@touchtonecorp.com> wrote:

> On 1/21/14 9:59 AM, David kerber wrote:
>> You can update the single .jsp on the server, in at least some
>> situations.  I do that occasionally when I need to get an update out and
>> can't take the service down.
> 
> But note that if and when you DO replace the WAR file, it will stomp on whatever changes you've made in the context.
> 

You can get around this if you deploy from an exploded WAR directory instead of a WAR file.  As an example, the manager application does this.

Dan

> 
> ---------------------------------------------------------------------
> 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: How to update a web app without uploading the WAR

Posted by "James H. H. Lampert" <ja...@touchtonecorp.com>.
On 1/21/14 9:59 AM, David kerber wrote:
> You can update the single .jsp on the server, in at least some
> situations.  I do that occasionally when I need to get an update out and
> can't take the service down.

But note that if and when you DO replace the WAR file, it will stomp on 
whatever changes you've made in the context.

--
JHHL
(speaking from bitter experience)


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


Re: How to update a web app without uploading the WAR

Posted by David kerber <dc...@verizon.net>.
You can update the single .jsp on the server, in at least some 
situations.  I do that occasionally when I need to get an update out and 
can't take the service down.


On 1/21/2014 12:02 PM, Chris Patterson wrote:
> Hello,
>
> My WAR file is becoming every time bigger and bigger,
> images are included and also some documents like PDFs
>
> Sometimes we need to change little code in only one jsp file,
> perhaps someone can help figuring out alternatives to upload
> and update specific changes to code regarding one single file ?
>
> I am using Tomcat 7.0.50, with Apache, using mod_jk working fine
> and usually deploying the web app with the tomcat manager on a
> Centos release 6.5
>
> WAR is allready over 120M size.
>
> Thanks,
> Wilhelm.
>
> ---------------------------------------------------------------------
> 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


How to update a web app without uploading the WAR

Posted by Chris Patterson <to...@vittox.com>.
Hello,

My WAR file is becoming every time bigger and bigger,
images are included and also some documents like PDFs

Sometimes we need to change little code in only one jsp file,
perhaps someone can help figuring out alternatives to upload
and update specific changes to code regarding one single file ?

I am using Tomcat 7.0.50, with Apache, using mod_jk working fine
and usually deploying the web app with the tomcat manager on a
Centos release 6.5

WAR is allready over 120M size.

Thanks,
Wilhelm.

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


Re: Precompiling JSPs while deploying the application in Tomcat

Posted by java developer <re...@gmail.com>.
This<http://tomcat.apache.org/tomcat-7.0-doc/jasper-howto.html#Production_Configuration>might
help you.



On Tue, Dec 10, 2013 at 3:28 PM, Tapajyoti Roybarman <
tapajyoti.roybarman@tcs.com> wrote:

> Hi Team,
>
> Is there any Tomcat setting through which all the JSPs available in my
> package will get compiled while I deploy the application. Normally a JSP
> gets compiled while it is being requested and gets collected inside Work
> folder. I want that all the JSPs in my package should get compiled while
> the deployment process.
>
> Tomcat Version - apache-tomcat-7.0.27
>
> OS - Windows 7
>
> Thanks in advance.
>
> Best Regards,
>
> Tapajyoti Roy Barman
> Mailto: tapajyoti.roybarman@tcs.com
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>

Precompiling JSPs while deploying the application in Tomcat

Posted by Tapajyoti Roybarman <ta...@tcs.com>.
Hi Team,

Is there any Tomcat setting through which all the JSPs available in my 
package will get compiled while I deploy the application. Normally a JSP 
gets compiled while it is being requested and gets collected inside Work 
folder. I want that all the JSPs in my package should get compiled while 
the deployment process.

Tomcat Version - apache-tomcat-7.0.27

OS - Windows 7

Thanks in advance.

Best Regards,

Tapajyoti Roy Barman
Mailto: tapajyoti.roybarman@tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you



Re: Need Information regarding Apache Webserver static file configuration

Posted by André Warnier <aw...@ice-sa.com>.
Tapajyoti Roybarman wrote:
> Hi Andre,
> 
> Finally it worked!!!!!!!!!!!!!!!!!!! Thanks a ton.
> 
> Below is the setting that I used.
> 
> ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! http://localhost:8080/
> ProxyPassMatch ^/(.*/servlet/.*)$ http://localhost:8080/$1
> ProxyPassMatch ^/(.*\.jsp)$ http://localhost:8080/$1
> 
> Now, One final question.
> 
> I am using the below settings for Load balancing.
> 
> <VirtualHost *:80>
> ProxyRequests off 
> ServerName localhost
> <Proxy balancer://mycluster>
> BalancerMember http://localhost:8081/
> BalancerMember http://localhost:8082/
> Order Deny,Allow
> Deny from none
> Allow from all
> ProxySet lbmethod=byrequests
> </Proxy>
> ProxyPass /balancer-manager !
> ProxyPass / balancer://mycluster/
> </VirtualHost>
> 
> How do I merge this with the static content settings (ProxyPassMatch ) 
> that I have used above. Please note that both settings are working fine 
> when given individually. But how am I supposed to combine these two?
> 

Honestly, I do not have a clue.  I am not familiar with the load-balancing via mod_proxy.
I will make a guess though, and suppose that it would be along the lines of :

 > ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! balancer://mycluster/
 > ProxyPassMatch ^/(.*/servlet/.*)$ balancer://mycluster/$1
 > ProxyPassMatch ^/(.*\.jsp)$ balancer://mycluster/$1

(and then probably also remove the line
 > ProxyPass / balancer://mycluster/
)

But now we're really getting into httpd- and mod_proxy-specific questions, so you might 
want to switch to the httpd list for more accurate information.


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


Re: Need Information regarding Apache Webserver static file configuration

Posted by Tapajyoti Roybarman <ta...@tcs.com>.
Hi Andre,

Finally it worked!!!!!!!!!!!!!!!!!!! Thanks a ton.

Below is the setting that I used.

ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! http://localhost:8080/
ProxyPassMatch ^/(.*/servlet/.*)$ http://localhost:8080/$1
ProxyPassMatch ^/(.*\.jsp)$ http://localhost:8080/$1

Now, One final question.

I am using the below settings for Load balancing.

<VirtualHost *:80>
ProxyRequests off 
ServerName localhost
<Proxy balancer://mycluster>
BalancerMember http://localhost:8081/
BalancerMember http://localhost:8082/
Order Deny,Allow
Deny from none
Allow from all
ProxySet lbmethod=byrequests
</Proxy>
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/
</VirtualHost>

How do I merge this with the static content settings (ProxyPassMatch ) 
that I have used above. Please note that both settings are working fine 
when given individually. But how am I supposed to combine these two?

Thanks again for all your help.

Tapajyoti Roy Barman
Ph:- +919433040094
Mailto: tapajyoti.roybarman@tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you



Re: Need Information regarding Apache Webserver static file configuration

Posted by Tapajyoti Roybarman <ta...@tcs.com>.
Hi Andre,

Finally it worked!!!!!!!!!!!!!!!!!!! Thanks a ton.

Below is the setting that I used.

ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! http://localhost:8080/
ProxyPassMatch ^/(.*/servlet/.*)$ http://localhost:8080/$1
ProxyPassMatch ^/(.*\.jsp)$ http://localhost:8080/$1

Now, One final question.

I am using the below settings for Load balancing.

<VirtualHost *:80>
ProxyRequests off 
ServerName localhost
<Proxy balancer://mycluster>
BalancerMember http://localhost:8081/
BalancerMember http://localhost:8082/
Order Deny,Allow
Deny from none
Allow from all
ProxySet lbmethod=byrequests
</Proxy>
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/
</VirtualHost>

How do I merge this with the static content settings (ProxyPassMatch ) 
that I have used above. Please note that both settings are working fine 
when given individually. But how am I supposed to combine these two?

Thanks again for all your help.

Tapajyoti Roy Barman
Ph:- +919433040094
Mailto: tapajyoti.roybarman@tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you



Re: Need Information regarding Apache Webserver static file configuration

Posted by André Warnier <aw...@ice-sa.com>.
Tapajyoti Roybarman wrote:
> Hi Andre,
> 
> I apologize for not following the mailing rule. Actually this is the first 
> time that I am taking the help of such a forum.
> 
> Before I begin asking you anything I want to thank you for such a detailed 
> explanation.
> 
> To begin with, answer to your question - "why do you want to serve these 
> files from Apache httpd, instead of letting Tomcat do it?" I am planning 
> to use Apache httpd as a Load Balancer. And to improve the performance of 
> my application, I want to serve the static content from apache itself.
> 
> Now, as per your suggestion I have modified the entries of httpd.conf file 
> to this.
> 
> ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! http://localhost:8080/
> ProxyPassMatch ^/(.*\.jsp)$ http://localhost:8080/$1
> ProxyPassReverse / http://localhost:8080/
> 
> ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! http://localhost:8080/ - By using 
> this setting I am able to serve static files from apache. I have kept my 
> files under DocumentRoot as per your suggestion.
> 
> ProxyPassMatch ^/(.*\.jsp)$ http://localhost:8080/$1 - If I am not using 
> this. I am getting a page not found error for my page Login.jsp present 
> inside Tomcat/Webapps/MyApplication. When I am using this setting I am 
> able to reach to the page Login.jsp.
> 
> Now, the probelm is, the Login.jsp actually sends the request to a servlet 
> to complete the login functionality. I am not able to reach to that 
> servlet using the above settings. The URL  is - 
> http://localhost/MyApplication/servlet/login
> 
> What should I add in the httpd.conf to achieve this?

Assuming that all the URLs which contain "/servlet/" are to be forwarded to Tomcat,
you could use something like :

ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! http://localhost:8080/
ProxyPassMatch ^/(.*\.jsp)$ http://localhost:8080/$1
ProxyPassMatch ^/(.*/servlet/.*)$ http://localhost:8080/$1

ProxyPassReverse / http://localhost:8080/


Note : still be careful of the order of the directives.  As indicated in the corresponding 
mod_proxy documentation, httpd evaluates each Proxy* directive in turn, from top to 
bottom, and the first one that matches "wins the day".
For example, if you had this order :

ProxyPassMatch ^/(.*\.jsp)$ http://localhost:8080/$1
ProxyPassMatch ^/(.*/servlet/.*)$ http://localhost:8080/$1
ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! http://localhost:8080/

then a URL like
http://localhost/MyApplication/servlet/something/image.jpg
would be proxied to Tomcat, because the line
ProxyPassMatch ^/(.*/servlet/.*)$ http://localhost:8080/$1
would match before the line
ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! http://localhost:8080/

As I recall, httpd has an internal flag that means "proxy this URL" or "don't proxy this 
URL".  As soon as one of the expressions in a Proxy* statement matches, that flag is set 
(one way or the other), and no further evaluation of Proxy* statements takes place.

That also means that if you happen to know that there are many more URLs containing 
"/servlet/" than there are ending in ".jsp", you could do some (very small) optimisation 
by doing this :
ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! http://localhost:8080/
ProxyPassMatch ^/(.*/servlet/.*)$ http://localhost:8080/$1
ProxyPassMatch ^/(.*\.jsp)$ http://localhost:8080/$1


Alternatively again : if, once you have "filtered out" all URLs ending in 
(gif|jpg|css|png), you know that all the remaining ones that start with "/MyApplication" 
should be forwarded to Tomcat, then you could use :

ProxyPassMatch ^/.*\.(gif|jpg|css|png)$ ! http://localhost:8080/
ProxyPassMatch ^/MyApplication http://localhost:8080/MyApplication

and that would take care of both
/MyApplication/servlet/login
/MyApplication/Login.jsp
and many others.

It's fun playing with..
And mod_rewrite is even more fun.



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


Re: Need Information regarding Apache Webserver static file configuration

Posted by Tapajyoti Roybarman <ta...@tcs.com>.
Hi Andre,

I apologize for not following the mailing rule. Actually this is the first 
time that I am taking the help of such a forum.

Before I begin asking you anything I want to thank you for such a detailed 
explanation.

To begin with, answer to your question - "why do you want to serve these 
files from Apache httpd, instead of letting Tomcat do it?" I am planning 
to use Apache httpd as a Load Balancer. And to improve the performance of 
my application, I want to serve the static content from apache itself.

Now, as per your suggestion I have modified the entries of httpd.conf file 
to this.

ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! http://localhost:8080/
ProxyPassMatch ^/(.*\.jsp)$ http://localhost:8080/$1
ProxyPassReverse / http://localhost:8080/

ProxyPassMatch ^/.*\.(gif|jpg|css|png)$! http://localhost:8080/ - By using 
this setting I am able to serve static files from apache. I have kept my 
files under DocumentRoot as per your suggestion.

ProxyPassMatch ^/(.*\.jsp)$ http://localhost:8080/$1 - If I am not using 
this. I am getting a page not found error for my page Login.jsp present 
inside Tomcat/Webapps/MyApplication. When I am using this setting I am 
able to reach to the page Login.jsp.

Now, the probelm is, the Login.jsp actually sends the request to a servlet 
to complete the login functionality. I am not able to reach to that 
servlet using the above settings. The URL  is - 
http://localhost/MyApplication/servlet/login

What should I add in the httpd.conf to achieve this?

Thanks and Best Regards,

Tapajyoti Roy Barman

Ph:- +919433040094
Mailto: tapajyoti.roybarman@tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you



Re: Need Information regarding Apache Webserver static file configuration

Posted by André Warnier <aw...@ice-sa.com>.
Hi.

First, respond only to the list, do not copy people extra.
I get every message to the list anyway, and if you copy me I get an extra copy which I do 
not need.

Second, on this list, it is preferred to send responses in the text of the original 
message, not on top. See : http://tomcat.apache.org/lists.html - tomcat users - Important 
- item #6.

Tapajyoti Roybarman wrote:
> Hi Andre,
> 
> Thanks a lot for the quick response.
> 
> In my httpd.conf file I have added the below settings.
> 
> ProxyPass / http://localhost:8080/

This is what causes all requests to be forwarded to Tomcat.

> ProxyPassReverse / http://localhost:8080/

This can stay as it is, it plays a role only for "redirect" responses from Tomcat.

> 
> This is to connect Apache Webserver and Tomcat. In future I would add more 
> clusters and then modify the httpd.conf file accordingly.
> 
> Now because of this setting everything is being redirected to Tomcat. Even 
> the static files are displayed from my application stack inside Tomcat 
> Webapps.
> 
> Now, if I want to just do the opposite (from what you suggested) and add 
> exceptions for files like jpg, png, css etc in my httpd.conf file, how do 
> I do that? 
> 
> Hope I was able to make my question clear.

Yes.

Maybe the first question would be : why do you want to serve these files from Apache 
httpd, instead of letting Tomcat do it ?
Do you /need/ an Apache httpd front-end for any other reason than to serve these files ?
Tomcat itself can perfectly well be configured to answer on port 80 like any normal 
webserver, and is quite efficient at serving static content such as these files.
So why complicate your life ?

But if you do have a valid reason to have a front-end Apache httpd (one of those would be 
if you need to run non-Java cgi-bin scripts or such things; another one would be to use 
httpd as a load-balancer also), then :

There are a multitude of possibilities, and I cannot go through all of them here (also 
considering that this is a Tomcat list, not a httpd list).

a) For simple cases, you may want to look at this :
http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassmatch
In other words, replace the line
ProxyPass / http://localhost:8080/
by something more like :
ProxyPassMatch ^/.*\.(gif|jpg|css|...)$ ! http://localhost:8080/

Be careful of the remark on the same page about "Ordering ProxyPass Directives".

Also check if it is not easier to use
ProxyPassMatch ^/(.*\.jsp)$ http://localhost:8080/$1
(if all you want to proxy to Tomcat are calls to JSP pages)

b) for more complex cases, you will need to use the mod_rewrite module, as it says in the 
above page.
See : http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule
and siblings.

You can also use <Location> and <LocationMatch> sections in Apache httpd, and put your 
ProxyPass directives inside of these sections.

Which is the best way ? It depends...


 > Where in my Apache2.2 folder structure do I keep the static
 > contents?

Apache httpd expects the requested resources to be located somewhere below the directory 
named in the "DocumentRoot" directive of your configuration.
So for example :
- if "DocumentRoot" was "/var/www/myhost/docs/"
- and you currently have an image at (tomcat_base)/webapps/yourapp/images/image.jpg
(served for the request URL http://localhost:8080/yourapp/images/image.jpg)
you would need to move it to a directory :
/var/www/myhost/docs/yourapp/images/image.jpg
in order for it to be served by Apache for the request URL : 
http://localhost/yourapp/images/image.jpg)

That is because, once Apache has decided that it will not forward this request to Tomcat, 
it will then interpret the request URL according to its own rules.

(Note : you can modify this smartly with other RewriteRule's, but that is an exercise for 
level-2 httpd gurus)


And /do not/ set DocumentRoot to (tomcat_base)/webapps or anything like that, because that 
would create a big security hole.
(read : http://tomcat.apache.org/connectors-doc/reference/apache.html)
Keep the Apache DocumentRoot and the Tomcat webapps directories well-separated, unless and 
until you know exactly what you are doing, and unless you are prepared to explain this in 
detail to whoever will maintain that website after you.

Note also that mod_proxy_http is not the only way available to connect Apache httpd and 
Tomcat.  There are also mod_proxy_ajp and mod_jk, each one of them with its own advantages 
and inconvenients compared to mod_proxy_http.


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


Re: Need Information regarding Apache Webserver static file configuration

Posted by Daniel Mikusa <dm...@gopivotal.com>.
On Dec 4, 2013, at 8:29 AM, Tapajyoti Roybarman <ta...@tcs.com> wrote:

> Hi Andre,
> 
> Thanks a lot for the quick response.
> 
> In my httpd.conf file I have added the below settings.
> 
> ProxyPass / http://localhost:8080/
> ProxyPassReverse / http://localhost:8080/
> 
> This is to connect Apache Webserver and Tomcat. In future I would add more 
> clusters and then modify the httpd.conf file accordingly.
> 
> Now because of this setting everything is being redirected to Tomcat. Even 
> the static files are displayed from my application stack inside Tomcat 
> Webapps.
> 
> Now, if I want to just do the opposite (from what you suggested) and add 
> exceptions for files like jpg, png, css etc in my httpd.conf file, how do 
> I do that?

See ProxyPass directive here.  It tells how to exclude resources.  Make sure you read the part about properly ordering your ProxyPass statements too.

  https://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass

> Where in my Apache2.2 folder structure do I keep the static 
> contents?

In your htdocs (i.e. DocumentRoot) folder.  Exactly where under that folder just depends on where your application expects it.  If your app stores static resources under a "static" folder (i.e. /static/images/...) then you'd just create that folder structure under the htdocs folder.

Dan

> 
> Hope I was able to make my question clear.
> 
> Eagerly waiting for your response.
> 
> Thanks and Best Regards,
> 
> Tapajyoti Roy Barman
> Ph:- +919433040094
> Mailto: tapajyoti.roybarman@tcs.com
> ____________________________________________
> Experience certainty.   IT Services
>                        Business Solutions
>                        Consulting
> ____________________________________________
> 
> 
> 
> From:
> André Warnier <aw...@ice-sa.com>
> To:
> Tomcat Users List <us...@tomcat.apache.org>
> Date:
> 12/04/2013 06:45 PM
> Subject:
> Re: Need Information regarding Apache Webserver static file configuration
> 
> 
> 
> Tapajyoti Roybarman wrote:
>> Hi,
>> 
>> Could you please let me know that how can I serve static content like 
>> image files, css files through Apache Webserver instead of Tomcat? 
> 
> That is the normal thing that an Apache httpd webserver does.
> 
> Please
>> let me know about all the required configurations in detail.
> 
> That infomation is available on-line : http://httpd.apache.org/docs/2.2/
> 
>  I am
>> connecting Apache webserver and Tomcat using mod_proxy_http module.
> 
> Right. So *unless you specify otherwise*, all content will be served by 
> Apache httpd.
> It is only *when you explicitly specify otherwise* that Apache httpd will 
> forward some 
> requests to Tomcat.
> 
> Sugestion : from your Apache httpd configuration,
> 1) start by removing anything that refers to mod_proxy_http.
> Once you have done that, *everything* will be served by Apache httpd 
> (image files, css 
> files, html pages, everything).
> 2) once you have succeeded in the above, /then/ re-introduce your 
> mod_proxy_httpd-related 
> statements, to *selectively* forward some URLs to Tomcat.
> Et voilà !
> 
> It reminds me a bit of the story about a sculptor, who was aked how he 
> sculpted a horse 
> from a big block of stone.  He answered that it was very easy : you just 
> remove from the 
> stone everything that is not a horse.
> 
>  Also,
>> please find below some information that you may require.
>> 
> 
> That was good of you to supply this information. Many people do not, and 
> that always 
> causes delayed responses.
> 
> 
>> Apache Webserber Version  - 2.2.25
>> 
>> Apache Tomcat Version - 7.0.27
>> 
>> OS - Windows 7
>> 
>> Thanks in advance,
>> 
>> Best Regards,
>> 
>> Tapajyoti Roy Barman
>> Ph:- +919433040094
>> Mailto: tapajyoti.roybarman@tcs.com
>> =====-----=====-----=====
>> Notice: The information contained in this e-mail
>> message and/or attachments to it may contain 
>> confidential or privileged information. If you are 
>> not the intended recipient, any dissemination, use, 
>> review, distribution, printing or copying of the 
>> information contained in this e-mail message 
>> and/or attachments to it are strictly prohibited. If 
>> you have received this communication in error, 
>> please notify us by reply e-mail or telephone and 
>> immediately and permanently delete the message 
>> and any attachments. Thank you
>> 
>> 
>> 
> 
> 
> ---------------------------------------------------------------------
> 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: Need Information regarding Apache Webserver static file configuration

Posted by Tapajyoti Roybarman <ta...@tcs.com>.
Hi Andre,

Thanks a lot for the quick response.

In my httpd.conf file I have added the below settings.

ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/

This is to connect Apache Webserver and Tomcat. In future I would add more 
clusters and then modify the httpd.conf file accordingly.

Now because of this setting everything is being redirected to Tomcat. Even 
the static files are displayed from my application stack inside Tomcat 
Webapps.

Now, if I want to just do the opposite (from what you suggested) and add 
exceptions for files like jpg, png, css etc in my httpd.conf file, how do 
I do that? Where in my Apache2.2 folder structure do I keep the static 
contents?

Hope I was able to make my question clear.

Eagerly waiting for your response.

Thanks and Best Regards,

Tapajyoti Roy Barman
Ph:- +919433040094
Mailto: tapajyoti.roybarman@tcs.com
____________________________________________
Experience certainty.   IT Services
                        Business Solutions
                        Consulting
____________________________________________



From:
André Warnier <aw...@ice-sa.com>
To:
Tomcat Users List <us...@tomcat.apache.org>
Date:
12/04/2013 06:45 PM
Subject:
Re: Need Information regarding Apache Webserver static file configuration



Tapajyoti Roybarman wrote:
> Hi,
> 
> Could you please let me know that how can I serve static content like 
> image files, css files through Apache Webserver instead of Tomcat? 

That is the normal thing that an Apache httpd webserver does.

Please
> let me know about all the required configurations in detail.

That infomation is available on-line : http://httpd.apache.org/docs/2.2/

  I am
> connecting Apache webserver and Tomcat using mod_proxy_http module.

Right. So *unless you specify otherwise*, all content will be served by 
Apache httpd.
It is only *when you explicitly specify otherwise* that Apache httpd will 
forward some 
requests to Tomcat.

Sugestion : from your Apache httpd configuration,
1) start by removing anything that refers to mod_proxy_http.
Once you have done that, *everything* will be served by Apache httpd 
(image files, css 
files, html pages, everything).
2) once you have succeeded in the above, /then/ re-introduce your 
mod_proxy_httpd-related 
statements, to *selectively* forward some URLs to Tomcat.
Et voilà !

It reminds me a bit of the story about a sculptor, who was aked how he 
sculpted a horse 
from a big block of stone.  He answered that it was very easy : you just 
remove from the 
stone everything that is not a horse.

  Also,
> please find below some information that you may require.
>

That was good of you to supply this information. Many people do not, and 
that always 
causes delayed responses.


> Apache Webserber Version  - 2.2.25
> 
> Apache Tomcat Version - 7.0.27
> 
> OS - Windows 7
> 
> Thanks in advance,
> 
> Best Regards,
> 
> Tapajyoti Roy Barman
> Ph:- +919433040094
> Mailto: tapajyoti.roybarman@tcs.com
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain 
> confidential or privileged information. If you are 
> not the intended recipient, any dissemination, use, 
> review, distribution, printing or copying of the 
> information contained in this e-mail message 
> and/or attachments to it are strictly prohibited. If 
> you have received this communication in error, 
> please notify us by reply e-mail or telephone and 
> immediately and permanently delete the message 
> and any attachments. Thank you
> 
> 
> 


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




Re: Need Information regarding Apache Webserver static file configuration

Posted by André Warnier <aw...@ice-sa.com>.
Tapajyoti Roybarman wrote:
> Hi,
> 
> Could you please let me know that how can I serve static content like 
> image files, css files through Apache Webserver instead of Tomcat? 

That is the normal thing that an Apache httpd webserver does.

Please
> let me know about all the required configurations in detail.

That infomation is available on-line : http://httpd.apache.org/docs/2.2/

  I am
> connecting Apache webserver and Tomcat using mod_proxy_http module.

Right. So *unless you specify otherwise*, all content will be served by Apache httpd.
It is only *when you explicitly specify otherwise* that Apache httpd will forward some 
requests to Tomcat.

Sugestion : from your Apache httpd configuration,
1) start by removing anything that refers to mod_proxy_http.
Once you have done that, *everything* will be served by Apache httpd (image files, css 
files, html pages, everything).
2) once you have succeeded in the above, /then/ re-introduce your mod_proxy_httpd-related 
statements, to *selectively* forward some URLs to Tomcat.
Et voilà !

It reminds me a bit of the story about a sculptor, who was aked how he sculpted a horse 
from a big block of stone.  He answered that it was very easy : you just remove from the 
stone everything that is not a horse.

  Also,
> please find below some information that you may require.
>

That was good of you to supply this information. Many people do not, and that always 
causes delayed responses.


> Apache Webserber Version  - 2.2.25
> 
> Apache Tomcat Version - 7.0.27
> 
> OS - Windows 7
> 
> Thanks in advance,
> 
> Best Regards,
> 
> Tapajyoti Roy Barman
> Ph:- +919433040094
> Mailto: tapajyoti.roybarman@tcs.com
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain 
> confidential or privileged information. If you are 
> not the intended recipient, any dissemination, use, 
> review, distribution, printing or copying of the 
> information contained in this e-mail message 
> and/or attachments to it are strictly prohibited. If 
> you have received this communication in error, 
> please notify us by reply e-mail or telephone and 
> immediately and permanently delete the message 
> and any attachments. Thank you
> 
> 
> 


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