Como usar o CouchDB por trás do proxy reverso do Apache?

1

Acabei de instalar o CouchDB a partir do código-fonte em meu Debian com o apache 2.4.10.

$ curl http://localhost:5984/                                                                                                    
{"couchdb":"Welcome","uuid":"76929f1fc6f1e2c01edcd5b712fff044","version":"1.6.1","vendor":{"version":"1.6.1","name":"The Apache Software Fou
ndation"}}

Eu quero usá-lo através do https Apache Reverse Proxy:

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory /> 
        Options FollowSymLinks
        AllowOverride All
        SSLRequireSSL

    </Directory>

    #For using my owncloud and wiki without HTTP AUTH, and all the rest
    #with HTTP AUTH
    <LocationMatch "^/(?!owncloud|wiki)">
        AuthType Basic
        AuthName "Acces Restreint"
        AuthBasicProvider file
        AuthUserFile /home/...myfile
        Require valid-user      
        AllowOverride All
    </LocationMatch>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

    #Here I try to configure my reverse proxy for accessing CouchDB through https://example.com/couchdb/
    <Location /couchdb>
        ProxyPass http://localhost:5984/ ttl=60
        ProxyPassReverse http://localhost:5984/
        ProxyPassReverseCookieDomain localhost example.com
        RequestHeader set Origin "http://localhost:5984"
        AllowOverride all

        AuthType Basic
        AuthName "Acces Restreint"
        AuthUserFile /home/...myfile
        Require valid-user      
    </Location>

    SSLProxyEngine On
    SSLEngine on
    SSLCertificateFile /..../file.pem




    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
        SSLOptions +StdEnvVars
    </Directory>


    BrowserMatch "MSIE [2-6]" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
    # MSIE 7 and newer should be able to use keepalive
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

</VirtualHost>
</IfModule>

Mas quando tento me conectar pela internet para: link

Eu obtenho o seguinte resultado:

{"error":"unauthorized","reason":"Name or password is incorrect."}

Parece que o couchdb está respondendo, mas por que ele requer uma autorização enquanto não está usando:

$curl http://localhost:5984/    

Alguma pista?

    
por Maxx 01.03.2016 / 15:15

1 resposta

1

Encontrou! Eu tive que desanexar o cabeçalho de autorização:

Também tive que alterar o link para o link

    <Location /couchdb> 
            ProxyPass http://localhost:5984 ttl=60
            ProxyPassReverse http://localhost:5984
            ProxyPassReverseCookieDomain localhost example.com
            RequestHeader set Origin "http://localhost:5984" 
            RequestHeader unset Authorization
            AllowOverride all 

            AuthType Basic 
            AuthName "Acces Restreint" 
            AuthUserFile /...
            Require valid-user 
    </Location> 
    
por 02.03.2016 / 15:54