Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 606B3102E4 for ; Wed, 4 Dec 2013 14:35:06 +0000 (UTC) Received: (qmail 3150 invoked by uid 500); 4 Dec 2013 14:34:59 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 3080 invoked by uid 500); 4 Dec 2013 14:34:59 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 3065 invoked by uid 99); 4 Dec 2013 14:34:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Dec 2013 14:34:57 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of aw@ice-sa.com designates 212.85.38.228 as permitted sender) Received: from [212.85.38.228] (HELO tor.combios.es) (212.85.38.228) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Dec 2013 14:34:49 +0000 Received: from [192.168.245.216] (montserrat.wissensbank.com [212.85.37.175]) (Authenticated sender: andre.warnier@ice-sa.com) by tor.combios.es (Postfix) with ESMTPA id 1673B3C3479 for ; Wed, 4 Dec 2013 15:34:54 +0100 (CET) Message-ID: <529F3D72.1030508@ice-sa.com> Date: Wed, 04 Dec 2013 15:34:26 +0100 From: =?ISO-8859-1?Q?Andr=E9_Warnier?= Reply-To: Tomcat Users List User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Need Information regarding Apache Webserver static file configuration References: <1386146601.45844.ezmlm@tomcat.apache.org> <529F2AD3.5030203@ice-sa.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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 and 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