2016-04-10 57 views
0

Hy我想從apache網絡服務器使用couchdb,使用這個我必須向couchdb服務器發出cors請求。 所以我所做的就是創建一個新的虛擬主機配置的Apache看起來像這樣(localhost.maxbit89.conf):apache2和couchdb在apache2上啓用cors

<VirtualHost *:80> 
     ServerAlias localhost.maxbit89 
    ServerName localhost.maxbit89 

    ServerAdmin [email protected] 
    DocumentRoot /var/www/localhost.maxbit89 
    <Directory /var/www/localhost.maxbit89/> 
     Options Indexes FollowSymLinks MultiViews 
       AllowOverride None 

     # Always set these headers. 
     Header always set Access-Control-Allow-Origin "*" 
     Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" 
     Header always set Access-Control-Max-Age "1000" 
     Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token" 

     # Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request. 
     RewriteEngine On 
     RewriteCond %{REQUEST_METHOD} OPTIONS 
     RewriteRule ^(.*)$ $1 [R=200,L] 
    </Directory> 

    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost> 

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet 

但我tryed任何要求有spezified頭非。 所以任何機構都可以告訴我如何以正確的方式使用couchdb + apache?

回答

0

好的第一個問題是一些如何我的apache2配置在重新安裝Apache後發生了破壞。

我將通過添加這解決了/etc/couchdb/local.ini了第二個問題:

[httpd] 
enable_cors = true 

[cors] 
origins = *