Answer the question
In order to leave comments, you need to log in
How to proxy a request to a dynamic url?
Is it possible to proxy a request to a url that is the result of a regular expression in a location block?
For example:
I have a url of the form /path/to/example/(.*)
Such requests should be proxied for $1
What requests can happen: /path/to/example/http://google.com
/path/to/example//uploads/boobies.png
Everything after /path/to/example/
is a valid url to which the request should be proxied.
I do not understand how this can be arranged, and is it possible at all?
Answer the question
In order to leave comments, you need to log in
http {
server {
listen *:80
resolver 8.8.8.8;
location ~ /path/to/example/(.*) {
try_files $1 /path/to/proxy/$1
}
location ~ /path/to/proxy/(.*) {
proxy_pass http://$1;
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question