Welcome! Log In Create A New Profile

Advanced

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

Francis Daly
December 07, 2012 11:02AM
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
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: 185
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