nginx and tomcat integrated but how to serve static files
AJ Weber
aweber at comcast.net
Fri Dec 7 13:42:17 UTC 2012
I'm still relatively new to nginx but find it to be great.
My high-level recommendation would be twofold:
1) Make sure you define a "proxy_cache" (check the nginx website for
details on these directives). In there you can define further how to
cache anything that's even a bit "static" from tomcat. And if you're
overriding specific paths or regex'es from tomcat (like if you know
there are static images or something being served from your webapp that
you can't easily move out to the flat filesystem), you'll want to add
proxy_ignore_headers to override what tomcat is telling the browser, add
the proxy_cache_valid, the Cache-Control header (see #2), and maybe
"expires".
2) For images and other truly static content, add_header Cache-Control
with some reasonable values. This will tell any downstream proxies and
the actual client PC's to cache those images locally, so they won't be
continuously fetched from your server.
There is no "one size fits all", but the power contained in nginx is
really great. You just have to take some time to try the settings and
use something like fiddler on the desktop to see the differences when
you make changes. (Be sure to clear your local browser's cache between
tests!)
Good Luck!
On 12/7/2012 6:08 AM, Irfan Khan wrote:
>
> Hi pals,
>
>
> I have my applications running on tomcat and to improve performance I
> have put nginx infront.Nginx proxy pass successfully pass all request
> to tomcat server.
>
> There are some html static files and images in my application which I
> don't to be served by tomcat. again, I am trying to as much as
> performance boost for my app.
>
> I am tried to do some research but unable to get solutions.
>
> please see my current config ans suggest!
>
> server {
> index index.html index.htm;
> listen 192.168.0.16:80;
> server_name localhost;
> location / {
> root /var/www/nginx-default;
> index index.html index.htm index.jsp;
> }
>
>
> location /abc/ {
> proxy_pass http://localhost:8080;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header Host $http_host;
>
> }
>
> thanks in advance!
>
> *Irfan Khan*
>
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20121207/7abc7b3b/attachment.html>
More information about the nginx
mailing list