14

I am loading images from an external site which I want to use in a 3D WebGL canvas. However this is not allowed due to origin.

The URL I am generating from the web page is as follows:

http://domain/somename/imagesproxy?url=http%3A%2F%2Fanothersite%2Fimage.png

Now I want to proxy_pass I assume, to the URL included in the request.

location /somename/imagesproxy {
     proxy_pass  ...
     proxy_set_header  host localhost;
}

How do I get nginx to dynamically proxy to different URL's

1
  • From what I have read nginx is not designed to be a forward proxy however I would like to use an nginx solution if possible.
    – sphvn
    Jul 27, 2012 at 13:04

2 Answers 2

9
proxy_pass $arg_uri;
2
  • 1
    It should be proxy_pass $arg_url; to exactly match the argument in the question.
    – puzzlement
    Jan 9, 2017 at 12:06
  • works great, BUT only if the "url" parameter is not urlencoded :(
    – jitbit
    Oct 26, 2020 at 8:11
-1
location = / {
    if ($args ~ "^url=(.+)") { #gets the "url" get parameter
        set $key1 $1;
        proxy_pass $key1; #use the parameter as proxy address
    }
}
1
  • 4
    This answer requires explanation.
    – kasperd
    Apr 8, 2016 at 10:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .