2

我正在尝试使用 X-Accel 将有关请求的信息传递给内部重定向的 uri。

  location / {
      root /web/external;
      include fastcgi.conf;
      fastcgi_param SCRIPT_FILENAME $document_root/check.php;
      fastcgi_pass unix:/services/.sock/fastcgi.sock;
   }       
   location /internal/ {
      internal;
      alias /web/internal;
      include fastcgi.conf;
      fastcgi_param SCRIPT_FILENAME $document_root/app.php;
      fastcgi_pass unix:/services/.sock/fastcgi.sock;
   }

check.php 将 X-Accel-Redirect 标头返回到 /internal/$uri 并发送我想传递给内部请求的其他标头值。我尝试使用 $sent_header_* 访问标题,但它似乎不起作用。

4

1 回答 1

1

我发现了一个似乎更适合我的用例的第 3 方模块。虽然我希望它是我能找到“内置”的东西

ngx_http_auth_request_module

http://mdounin.ru/hg/ngx_http_auth_request_module/file/tip/README http://mdounin.ru/hg/ngx_http_auth_request_module/file/tip/t/auth-request-set.t

配置将更改为:

location / {
    auth_request /check;
    auth_request_set $value $upstream_http_x_value;
    add_header X-Set-Value $value;
    root /web/internal;
    include fastcgi.conf;
    fastcgi_param SCRIPT_FILENAME $document_root/app.php;
    fastcgi_pass unix:/services/.sock/fastcgi.sock;
 }       
 location /check {
    internal;
    include fastcgi.conf;
    fastcgi_param SCRIPT_FILENAME $document_root/check.php;
    fastcgi_pass unix:/services/.sock/fastcgi.sock;
 }
于 2012-11-24T03:05:22.590 回答