Nginx – Do not expose HTTP 302 redirect by HTTP reverse proxy – handle it internally

apache-2.2httpnginxredirect

I'm creating a Facebook client for a very limited device – its web browser (ANT Galio) does not handle properly HTTP302 for source of images.

My UC looks like this – in web application markup profile images are placed in the manner:

<img src="http://reverseproxyfqdn/graph.facebook.com/profileId/picture/" />

When proxy asks for graph.facebook.com/profileId/picture/ it gets HTTP 302 redirect to different address, for example fbcdn-profile-a.akamaihd.net/someUrl. This response is reverse proxied to web browser with Location header changed to reverseproxyfqdn/fbcdn-profile-a.akamaihd.net/someUrl. All the web browsers I've tested handle it properly, but not ANT Galio. I need to return image got from fbcdn-profile-a.akamaihd.net/someUrl directly as a response to reverseproxyfqdn/graph.facebook.com/profileId/picture/ – so do not expose the whole HTTP 302 redirect story to the web browser.

Does anyone know how to do it in Nginx or Apache 2.2? I would like to avoid creating a special PHP/Perl/Java app for this and achieve it by HTTP server configuration.

Best Answer

You should consider the proxy_redirect directive which might help you dealing with this problem.