1

Is there a way to have nginx serve a remote HTTP image via HTTPS? I'm basically looking for an nginx-only alternative to the below PHP:

<?php
echo file_get_contents($_GET['url']);
3
  • Can you explain why you would want this? In what situation are you using this? What is wrong with the php solution? Feb 22, 2013 at 18:53
  • our site runs completely in HTTPS while some users post images in HTTP. Serving them via HTTP brings the annoying "some resources are not protected" message. If I could do it entirely in nginx I would save the PHP process.
    – mluggy
    Feb 22, 2013 at 18:58
  • plus nginx lets you cache resources via memcached so i'll be only retrieving them via http once.
    – mluggy
    Feb 22, 2013 at 19:06

1 Answer 1

0

You can use the proxy_pass directive with variables ($arg_* represents GET arguments):

location / {
    proxy_pass $arg_url;
    resolver 8.8.8.8;
}

Please pay attention, that this configuration effectively makes an open relay from your server. So, I do NOT recommend it for any production use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.