Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Use variable with nginx proxy_pass

$
0
0
Hi,

I'm new on nginx and I want to implement a particular configuration.

I set up a redirect URL http://mydomain.com/images/test/v1/03760089810361_D1C1_s89.jpg
to the URL http://anotherdomain.com/permalink/v1/1/4/preview/03760089810361_D1C1_s89.jpg?token=Ck8fP9xe
All this keeping the first URL.

To do this, I use the following configuration works properly :

server {
listen 80;
access_log /var/log/nginx/test.log;
server_name mydomain.com;
location /images/test/v1/03760089810361_D1C1_s89.jpg {
proxy_pass http://anotherdomain.com/permalink/v1/1/4/preview/03760089810361_D1C1_s89.jpg?token=Ck8fP9xe
}
}

I would like to use variables on the first URL to inject in the second.
So I could have a configuration of this type however, this one does not work :

server {
listen 80;
access_log /var/log/nginx/test.log;
server_name mydomain.com;
location /images/test/$1/$2 {
proxy_pass http://anotherdomain.com/permalink/$1/1/4/preview/$2?token=Ck8fP9xe
}
}

Can you give me the good configuration ?

Regards,

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>