【问题标题】:Apache doesn't see 'Authorization' header was sent via curlApache 没有看到“授权”标头是通过 curl 发送的
【发布时间】:2014-05-25 20:25:58
【问题描述】:

我不明白问题出在哪里。 我使用 curl 发送请求,如下所示:

curl --header "Authorization: Bearer asd421123eda" https://server/example

我使用的一个仅用于调试的服务器站点

 die("header: ".print_r(getallheaders()));

我得到以下信息(ips 和主机名被我更改了)

Array
(
    [Accept] => */*
    [User-Agent] => curl/7.30.0
    [Connection] => close
    [X-Accel-Internal] => /examp
    [X-Forwarded-For] => 19.13.131.123
    [X-Real-Ip] => 131.41.132.141
    [Host] => host.ht
)

如果我再放一些标题:

 curl --header "Authorization1: Bearer" https://serverexample.com

我在 headers 数组中看到了这个标头

 Array
 (
    [Authorization1] => Bearer
    [Accept] => */*
    .....
)

在我看来,apache 正在过滤某个授权标头。 你能告诉它为什么会这样,我该如何解决它。 提前致谢

【问题讨论】:

    标签: php apache curl http-headers authorization


    【解决方案1】:

    看来您正在将 apache2 作为 FastCGI 运行。由于 FastCGI apache 无法识别 Authorization 标头。您可以将此重写规则用作解决方法

    RewriteEngine on
    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
    

    【讨论】:

      猜你喜欢
      • 2020-10-23
      • 1970-01-01
      • 2023-02-23
      • 1970-01-01
      • 2018-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多