H
H
hellfleet2020-01-29 20:49:19
Nginx
hellfleet, 2020-01-29 20:49:19

How to correctly rewrite a query in NGINX?

Example
All requests go through proxy_pass (location /)

there is a request
https://domain.com/styles/x/d/f.png

It is necessary that the request
https://domain.com/x/d/f.png work as and https://domain.com/styles/x/d/f.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hellfleet, 2020-01-30
@hellfleet

location ~* $.png {
proxy_pass https://backend/styles/$1
...
}

D
dodo512, 2020-01-29
@dodo512

rewrite ^/x/d/f\.png$ /styles/x/d/f.png;
rewrite ^/(\d+/\d+/\d+\.png)$ /styles/$1;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question