3

我开发了一个 symfony2 宁静的后端,并且在本地一切正常。

所以我将应用程序部署在 apache2 服务器上(由 directadmin 包装),然后出现了奇怪的错误:

基本上,当我发送 DELETE(甚至 PUT/POST 它取决于 api)时,服务器会像 GET 一样响应。

为了更好地解释问题,我粘贴了 curl cmd 的日志:

$ curl -X DELETE website/api/sign/ -H "apiKey:7WJiHShAYPBI0asK1ZaKlJzpnn550X08" -v
* Hostname was NOT found in DNS cache
*   Trying <ip here>...
* Connected to www.website.com (<ip here>) port 80 (#0)
> DELETE /api/sign/ HTTP/1.1
> User-Agent: curl/7.35.0
> Host: www.website.com
> Accept: */*
> apiKey:7WJiHShAYPBI0asK1ZaKlJzpnn550X08
> 
< HTTP/1.1 200 OK
< Date: Sun, 29 Mar 2015 16:13:07 GMT
* Server Apache/2 is not blacklisted
< Server: Apache/2
< X-Powered-By: PHP/5.3.16
< Cache-Control: no-cache
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE
< Access-Control-Allow-Headers: X-Requested-With, origin, content-type, accept, apiKey
< X-Symfony-Cache: GET /api/sign/: miss
< Vary: Accept-Encoding,User-Agent
< Content-Length: 279
< Content-Type: application/json

那么内容就是相对于 GET 请求的内容......

实际上不明白为什么,但我已经添加了所有 OPTIONS api。

4

1 回答 1

1

SOLUTION:

http://forum.directadmin.com/showthread.php?t=35402

the issue was just that PUT and DELETE were disabled in httpd

change httpd.conf in this way solved the issue:

[old httpd.conf]

<Directory /home/*>
  AllowOverride All
  Options -MultiViews -Indexes FollowSymlinks IncludesNoExec +Includes
  <Limit GET POST OPTIONS PROPFIND>
    Order allow,deny
    Allow from all
  </Limit>
  <LimitExcept GET POST OPTIONS PROPFIND>
    Order deny,allow
    Deny from all
  </LimitExcept>
</Directory>

and

[new httpd.conf]

<Directory /home/*>
  AllowOverride All
  Options -MultiViews -Indexes FollowSymlinks IncludesNoExec +Includes
  <Limit GET POST OPTIONS PROPFIND PUT DELETE>
    Order allow,deny
    Allow from all
  </Limit>
  <LimitExcept GET POST OPTIONS PROPFIND PUT DELETE>
    Order deny,allow
    Deny from all
  </LimitExcept>
</Directory>
于 2015-03-29T17:44:47.220 回答