Question

I have an image that is served as static file using Nginx, but I need to call it with different GET parameters. Is it possible to proxypass those parameters to different server BUT (Here is the trick) return the static image back?

Thank you in advance.

Was it helpful?

Solution

If I'm understanding you correctly, you want to pass the request arguments to a different server, but mask this from the user by returning a static image?

If you can make the remote server return a 404, then this should work:

root /path/to/webroot;

location @otherserver {
    include proxy_params;
    proxy_pass http://some.other.server;
}

location /image.jpg {
    try_files @otherserver /real_image.jpg;
}

You could probably leverage the error_page directive to similar effect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top