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

Daniel asked:

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/" />

When proxy asks for it gets HTTP 302 redirect to different address, for example This response is reverse proxied to web browser with Location header changed to reverseproxyfqdn/ All the web browsers I’ve tested handle it properly, but not ANT Galio. I need to return image got from directly as a response to reverseproxyfqdn/ – 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.

My answer:

Don’t send the URLs to the browser in the first place. Instead, resolve them yourself on the server side while you’re creating the HTML pages and insert the CDN URLs in their place.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.