简体   繁体   English

apache2和couchdb在apache2上启用cors

[英]apache2 and couchdb enable cors on apache2

Hy I want to use couchdb from a apache webserver, to use this I have to make cors requests to the couchdb server. Hy,我想使用apache网站服务器上的couchbed,要使用它,我必须向该ouchdb服务器发出cors请求。 So what I did was creating a new VirtualHost config for apache that look like this(localhost.maxbit89.conf): 因此,我要做的是为apache创建一个新的VirtualHost配置,如下所示(localhost.maxbit89.conf):

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

    ServerAdmin webmaster@localhost
    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

But any request I tryed has non of the spezified headers. 但是我尝试的任何请求都没有特定的标题。 So can any body tell me how i use couchdb + apache the right way? 那么,有谁能告诉我如何正确使用couchdb + Apache?

Ok first problem was some how my apache2 config was broken after reinstalling apache the headers were send. 好的,第一个问题是重新安装apache标头后,我的apache2配置如何损坏。

I had a second problem that was solved by adding this to /etc/couchdb/local.ini: 我有第二个问题,可以通过将其添加到/etc/couchdb/local.ini来解决:

[httpd]
enable_cors = true

[cors]
origins = *

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM