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

sphvn
  • 245
  • 1
  • 2
  • 6
  • 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 '12 at 13:04

2 Answers2

9
proxy_pass $arg_uri;
VBart
  • 8,159
  • 3
  • 24
  • 25
-1
location = / {
    if ($args ~ "^url=(.+)") { #gets the "url" get parameter
        set $key1 $1;
        proxy_pass $key1; #use the parameter as proxy address
    }
}
Sven
  • 97,248
  • 13
  • 177
  • 225