phpnginxdokkux-accel-redirect

X-Accel-Redirect works from outside, but not from inside


So here's my thing. Got a php app running on nginx/dokku.

I have a location which is redirecting image assets. Say:

https://test.rokfor.ch/cdn/dummyimage.com/600x400/000/fff

Results in a image, shown in the Browser.

Calling the same resource within a php script like:

header('X-Accel-Redirect: /cdn/dummyimage.com/600x400/000/fff');
exit(0);

Results in an internal error. Nginx config looks like:

location ~ ^/cdn/(.*?)/(.*) {
  resolver 8.8.8.8;
  proxy_set_header HOST $1;
  proxy_pass "https://$1/$2?$args";
}

What could be potiential issues? Since I don't know in which direction to look.


Solution

  • Ok - found it out:

    Dokku runs internally Nginx 1.8 without SSL support. Proxy_pass to https therefore cannot work. I managed to work around the problem by forking the original heroku php buildpack, pushed the nginx dependency to 1.10 and added an additional repository providing a nginx version built with ssl support.