Welcome! Log In Create A New Profile

Advanced

Re: How to serve all existing static files directly with NGINX, but proxy other requests to jetty?

Francis Daly
November 18, 2014 03:54PM
On Tue, Nov 18, 2014 at 10:05:26AM -0500, AlexLuya wrote:

Hi there,

> I want to nginx to serve all static files that have been put at
> directories:js,images,html,and proxy other requests to jetty,I have tried:
>
> location ~ ^/test/(.*)\.
> (jpg|jpeg|gif|png|js|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$
> {
> root /ngixRoot/test;
> }

That says that if you request /test/file.jpg, nginx should send the
file /ngixRoot/test/test/file.jpg.

What response do you get?

What does the log file say is happening?

> After a squence of Q&A,I was told that "try_files" is another option(not
> sure which one is more propriate for my use case ),then after googling and
> reading,I tried this:
>
> location ~ ^/test/$ {
> try_files $uri $uri/ @jetty
> }

<snip>

> but get "403 forbidden" error,so please tell me what I did wrong?Thanks.

What request did you make, to get the 403 response? What response did
you want to get? What does the log file say about that request?

From your mail, it is not clear to me exactly what you want.

Possibly something like

root /nginxRoot/;
location /test/js/ {}
location /test/html/ {}
location /test/images/ {}
location / {
proxy_pass http://jetty;
# and whatever else is involved in jetty configuration
}

would come close?

If not, it might be helpful if you can describe what response you
want from a request for /test/js/file.js and for /test/js/missing.js,
for example. (Or have I misunderstood, and you actually care about
requests like /js/file.js?)

f
--
Francis Daly francis@daoine.org

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

How to serve all existing static files directly with NGINX, but proxy other requests to jetty?

AlexLuya November 18, 2014 10:05AM

Re: How to serve all existing static files directly with NGINX, but proxy other requests to jetty?

Francis Daly November 18, 2014 03:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 166
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