HTTP POST 请求和基本身份验证
HTTP POST request and basic authentication
当我这样做时:
curl https://example.com/my/ressource \
-H "Content-Type: application/json" \
--data '{"itemid":["123","456"]}' \
-u myuser
我收到 HTTP 403 Forbidden 错误代码。如果我使用 get 请求,它会起作用,例如
curl https://example.com/my/ressource
工作正常。此外,如果我在服务器端禁用基本身份验证,上述 post 请求工作正常。
服务器是 Apache 2.4,它充当反向代理。
post 请求有什么问题?
事实证明,在上述情况下,Apache 被用作反向代理,而 Apache 背后的服务器无法处理授权,因此解决方案是通过以下方式删除此 header:
RequestHeader unset Authorization
当我这样做时:
curl https://example.com/my/ressource \
-H "Content-Type: application/json" \
--data '{"itemid":["123","456"]}' \
-u myuser
我收到 HTTP 403 Forbidden 错误代码。如果我使用 get 请求,它会起作用,例如
curl https://example.com/my/ressource
工作正常。此外,如果我在服务器端禁用基本身份验证,上述 post 请求工作正常。
服务器是 Apache 2.4,它充当反向代理。
post 请求有什么问题?
事实证明,在上述情况下,Apache 被用作反向代理,而 Apache 背后的服务器无法处理授权,因此解决方案是通过以下方式删除此 header:
RequestHeader unset Authorization