1

I have a couchbase server behind a NGINX reverse proxy (behind the subpath /db).

How do I specify the correct connection string in Python?

I tried

from couchbase.cluster import Cluster, ClusterOptions
from couchbase.auth import PasswordAuthenticator 

cluster = Cluster('couchbase://testserver.com/db', ClusterOptions(
  PasswordAuthenticator('Administrator', 'password')))

But I get

ValueError: Cannot pass bucket to connection string: db

Accessing the admin website at https://testserver.com/db/_utils/index.html works.

NGINX configuration:

server {
        listen 80;
        server_name testserver.com;
        return 301 https://$server_name$request_uri;
        }

server {
        listen 443 ssl http2;

        server_name stagingpos.rsj.de;

        ssl_certificate /etc/ssl/xxx.crt;
        ssl_certificate_key /etc/ssl/xxx.key;

        location / {
                proxy_pass http://127.0.0.1:8001;
                proxy_set_header X-Forwarded-For $remote_addr;
                }
        location /db {
                rewrite /db/(.*) /$1 break;
                proxy_pass http://127.0.0.1:5984/;
                proxy_redirect off;
                proxy_buffering off;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Ssl on;
                }
        location /_session {
                proxy_pass http://127.0.0.1:5984/_session;
                proxy_redirect off;
                proxy_buffering off;
                proxy_set_header Host $host;
                proxy_set_header X_Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded_Ssl on;
                }

        }



Matthew Groves
  • 25,181
  • 9
  • 71
  • 121
Ruediger Jungbeck
  • 2,836
  • 5
  • 36
  • 59
  • So we can help you find the best solution, can you help us understand why you'd like to put proxy in front of Couchbase? – dnault Mar 23 '22 at 20:19
  • The idea is to have a Javascript web application directly accessing Pouchbase and Couchbase (and other web services (eg static files, application server) via https. Python based remote access via the reverse proxy would be primarily needed for testing (and could be done via other tunneling techniques like ssh tunnels if we can' t find a connect string). – Ruediger Jungbeck Mar 23 '22 at 21:48
  • I'm not sure if it is a good match for your use case, but here's an article that describes how to deploy nginx in front of Couchbase. The author's goal is to enable TLS for Couchbase Community Edition, but it also covers important details like configuring Couchbase to advertise alternate addresses. https://medium.com/@rajriteshchandra/coucbase-db-community-edition-tls-enablement-f6dd2eaafb0c – dnault Apr 07 '22 at 17:07

0 Answers0