Welcome! Log In Create A New Profile

Advanced

RE: nginx and tomcat integrated but how to serve static files

December 10, 2012 11:26AM
Hi,

Thanks for the suggestion, but unfortunately it didn't worked. I have tried
to create new location to be served by nginx but all requests goes to tomcat
by next location directive. Any html within /foo/ directory doesn't work at
all.
I am a newbie to Nginx and really loves it. I hope some regex combination
would help to solve the problem.

Please suggestion!

My config as follows;

Location /foo/*
Root /tomcat/webapps/abc/
Index.html

> 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;

}







Irfan Khan
Lead - IT

eNovate Media Solutions Pvt Ltd
#204, 2nd Floor, Cunningham Classic
22, Cunningham Road
Bangalore - 560052
Voice - + 91 80 41657660 | Mob - +91 903 589 38 14
www.enovatemedia.com


-----Original Message-----
From: nginx-bounces@nginx.org [mailto:nginx-bounces@nginx.org] On Behalf Of
Francis Daly
Sent: 07 December 2012 21:31
To: nginx@nginx.org
Subject: Re: nginx and tomcat integrated but how to serve static files

On Fri, Dec 07, 2012 at 04:38:20PM +0530, Irfan Khan wrote:

> 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.

nginx chooses how to handle a request based on the location{} blocks you
have defined.

Currently, you have: if it starts with /abc/, proxy to tomcat; otherwise,
serve from the filesystem.

So: which urls do you really want proxied to tomcat, and which do you really
want served from the filesystem?

If I guess that "url starts with /abc/ and ends in html" means "serve from
filesystem, not tomcat", then you could add one line:

> location /abc/ {

location ~ html$ {}

> 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;
>
> }

and a request for /abc/a.html will look for the file
/usr/local/nginx/html/abc/a.html (or strictly: abc/a.html below whatever you
have configured "root" to be).

Best would be to make the non-tomcat things be in a different url prefix to
the tomcat things -- such as /abc/static, for example -- because then you
could just use prefix locations. That depends on how your application is
written, which may not be changeable.

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

RE: nginx and tomcat integrated but how to serve static files

irfee December 07, 2012 06:10AM

Re: nginx and tomcat integrated but how to serve static files

aweber December 07, 2012 08:44AM

Re: nginx and tomcat integrated but how to serve static files

Francis Daly December 07, 2012 11:02AM

RE: nginx and tomcat integrated but how to serve static files

irfee December 10, 2012 11:26AM

Re: nginx and tomcat integrated but how to serve static files

Francis Daly December 10, 2012 02:50PM

RE: nginx and tomcat integrated but how to serve static files

irfee December 11, 2012 03:50AM

Re: nginx and tomcat integrated but how to serve static files

Francis Daly December 11, 2012 07:28AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 257
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready