Our site is an image repository of sorts. Each image has the notion of an external URL and an internal URL. External URL's are seen by clients and they change as we experiment with SEO. The internal URL's are permanent URL's that point to our image hosting service. We use our Ruby on Rails app to provide the URL translation. Here's an example of a request:
-------- ----- ------- ------- ------------
| | --eURL--> | | --> | | --> | | -iURL--> | |
|client| |CDN| |Nginx| | RoR | |Image Host|
| | <-------- | | <-- | | <-- | | <-IMG--- | |
-------- ----- ------- ------- ------------
The architecture is working, but streaming the image through RoR is inefficient. I want to have Nginx do the proxying. That's what it's for. The proposed architecture would look something like this:
-------- ----- ------- -------
| | --eURL--> | | --> | | ------> | RoR |
|client| |CDN| |Nginx| <-????- | |
| | <-------- | | <-- | | -------
-------- ----- | | ------------
| | -iURL-> |Image Host|
| | <-IMG-- | |
------- ------------
What response can I send to Nginx to have it proxy the data? I don't mind adding Nginx modules to my infrastructure and of course I'm open to changing my nginx.conf.
X-Sendfile is the closest thing I've found, but that only allows streaming from the local filesystem. Maybe there is some other obscure HTTP response header or status code I'm unaware of.