如何在 Apache 2.4/Jira 中允许 PUT HTTP 方法

如何在 Apache 2.4/Jira 中允许 PUT HTTP 方法

谁能告诉我如何在 Ubuntu 16.04 上全局启用 PUT HTTP 方法或仅针对 Apache 2.4 中的单个虚拟主机启用 PUT HTTP 方法?我已经尝试了几件事,但没有任何效果。我有 Jira 的反向代理配置。该配置适用于 GET 和 POST,但不适用于 PUT。简而言之,它看起来像这样:

<VirtualHost *:443>
SSLEngine on


# JIRA Proxy Configuration:
<Proxy *>
Order deny,allow
Allow from all
AllowMethods GET POST PUT DELETE OPTIONS
</Proxy>
SSLProxyEngine On
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>

我的第一种方法是在我的 Proxy * 配置中:

<Limit GET POST PUT DELETE OPTIONS>
Require all granted
</Limit> 

之后我尝试了

<RequireAny>
Require method DELETE GET POST PUT OPTIONS
</RequireAny>

最后我尝试了

AllowMethods GET POST PUT DELETE OPTIONS

我总是这样做

apachectl configtest
apachectl restart

什么都不起作用。每当我通过curl 执行 PUT 请求时,它都会显示

curl -H "Content-Type: application/json" -X PUT -d '{"comment": "I did some work here.","visibility": {"type": "group","value": "jira-developers"},"started": "2017-09-27T13:06:14.160+0000","timeSpentSeconds": 12000}' https:/hostname/rest/api/2/issue/blubb-11/worklog -vvvv
<snip>
> Content-Type: application/json
> Content-Length: 163
>
* upload completely sent off: 163 out of 163 bytes
< HTTP/1.1 405
< Date: Thu, 28 Sep 2017 14:23:45 GMT
< Server: Apache/2.4.18 (Ubuntu)
< X-AREQUESTID: 983x106858x1
< X-ASEN: SEN-4341829
< X-AUSERNAME: anonymous
< Allow: HEAD,POST,GET,OPTIONS
< X-Content-Type-Options: nosniff
< Content-Type: text/html;charset=UTF-8
< Content-Length: 0
</snip>

答案1

问题是来自我这边的格式错误的 Jira API Rest 请求。如果请求错误,即使 Rest 方法支持 PUT,Jira 也会发送有点误导性的“允许:HEAD、POST、GET、OPTIONS”。

相关内容