A
A
alexandre1082015-11-01 02:26:31
Nginx
alexandre108, 2015-11-01 02:26:31

Serving static with NGINX at specific addresses?

There is an address: /img/t1/123456/f.jpg/thumb_img
The config for statics NGINXlooks like this:

location ~* \.(jpg|jpeg|gif|png|ico|css|js)/thumb_img$ {
       root  /home/user/dev/img/;
}

NGINXAnd writes the following error in the logs :
[error] 15228#0: *1 open() "/home/user/dev/img/img/t1/123456/f.jpg/thumb_img" 
failed (2: No such file or directory), 
client: 127.0.0.1, server: site.dev, 
request: "GET /img/t1/123456/f.jpg/thumb_img HTTP/1.1", host: "site.dev"

What is the correct way to write a distribution of statics in this case, so that the content located at the address is distributed at the link indicated above /home/user/dev/img/?
PS version of nginx:
nginx -v
nginx version: nginx/1.4.6 (Ubuntu)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nirvimel, 2015-11-01
@alexandre108

rewrite (\w+\.(?:jpg|jpeg|gif|png))/thumb_img$ /img/$1 break;
location /img/ {
        root /home/user/dev;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question