【问题标题】:X-Accel-Redirect works from outside, but not from insideX-Accel-Redirect 从外部工作,但不能从内部工作
【发布时间】:2016-09-23 12:33:17
【问题描述】:

所以这是我的事。在 nginx/dokku 上运行了一个 php 应用程序。

我有一个正在重定向图像资产的位置。说:

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

生成图像,显示在浏览器中。

在 php 脚本中调用相同的资源,例如:

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

导致内部错误。 Nginx 配置如下:

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

什么可能是潜在的问题?因为我不知道该往哪个方向看。

【问题讨论】:

  • 错误日志中有什么内容?
  • 我收到了2016/10/03 12:20:59 [error] 249#0: *47 invalid URL prefix in "https://dummyimage.com/600x400/000/fff。似乎它与 ssl 有某种关系:如果我将位置更改为 proxy_pass "http://$1/$2?$args";(没有 https),它似乎可以工作。但这对我没有帮助 - 我需要 https!
  • 每当我想更改locationdirective 中的某些内容时,我都会收到nginx: [emerg] unknown directive "proxy_ssl_server_name" in /app/nginx_app.conf:6 之类的错误... Nginx 编译为--with-http_ssl_module 和1.10 版使用OpenSSL 构建。

标签: php nginx dokku x-accel-redirect


【解决方案1】:

好的 - 找到了:

Dokku 在没有 SSL 支持的情况下在 Nginx 1.8 内部运行。 Proxy_pass 到 https 因此 不能 工作。我设法通过分叉原始 heroku php buildpack 来解决这个问题,将 nginx 依赖项推送到 1.10 并添加了一个额外的存储库,提供了一个使用 ssl 支持构建的 nginx 版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多