Apache-Httpd
如何在 Apache 2.4/Jira 中允許 PUT HTTP 方法
誰能告訴我如何在 Ubuntu 16.04 上的 Apache 2.4 中全域啟用 PUT HTTP 方法或僅為單個 vHost 啟用?我已經嘗試了幾件事,但沒有任何工作。我有 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>
問題是來自我這邊的格式錯誤的 Jira API Rest 請求。如果請求錯誤,即使 Rest 方法支持 PUT,Jira 也會發送一些誤導性的“允許:HEAD、POST、GET、OPTIONS”。