Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change port not working for reverse proxy #254

Open
key262yek opened this issue Mar 1, 2024 · 0 comments
Open

Change port not working for reverse proxy #254

key262yek opened this issue Mar 1, 2024 · 0 comments

Comments

@key262yek
Copy link

key262yek commented Mar 1, 2024

I setup couchdb via rootless docker on Ubuntu 22.04, docker v25.0.3
with following compose

couchdb:
    image: couchdb:3.3.3
    container_name: couchdb
    restart: unless-stopped
    ports:
      - "9564:5984"
    networks:
      - monitoring
    environment:
      - COUCHDB_USER
      - COUCHDB_PASSWORD
    volumes:
      - couchdb_data:/opt/couchdb/data    
      - ./couchdb/local.ini:/opt/couchdb/etc/local.ini

As you can see, I change the port from 5984 to other.
It runs fine, and I can access Fauxton via http://localhost:9564/_utils

Since I want to reverse proxy db, I wrote haproxy.cfg

backend couchdb-http
        mode http
        balance roundrobin
        option httpchk GET /_up
        http-check disable-on-404
        server couchdb localhost:9564 check inter 5s
        timeout connect 4s
        timeout server 4s

frontend redirect
        mode http
        bind :::80 v4v6
        bind :::443 v4v6 ssl crt /etc/haproxy/certs/domain.pem

        http-request redirect scheme https code 301 unless { ssl_fc }
        http-response set-header Strict-Transport-Security "max-age=16000000; includeSubDomains; preload;"

        http-request set-header Host %[req.hdr(Host)]
        http-request set-header X-Forwarded-Proto https if { ssl_fc }

        use_backend couchdb-http

        timeout client 4s

But it fails with error couchdb-http/couchdb is DOWN, reason: Layer7 wrong status, code: 401, info: "Unauthorized"

If I change the port in backend from 9564 to 5984, it works.

Add
I can access both of two following addresses

>> curl localhost:5984
{"error":"unauthorized","reason":"Authentication required."}
>> curl localhost:9564
{"error":"unauthorized","reason":"Authentication required."}

Even if I change the chttpd port in fauxton configuration page, its behavior is same. (Should I restart after change configuration?)

Expected Behavior

Reverse proxy works with port 9564

Current Behavior

Reverse proxy works only with port 5984 even if I changed port in compose.yaml

Possible Solution

Steps to Reproduce (for bugs)

  1. run docker with different port from 5984
  2. reverse proxy with changed port
  3. Get "Unauthorized" error

Context

Your Environment

  • Version used: Couchdb 3.3.3
  • Browser Name and version: Safari 16.5.2
  • Operating System and version (desktop or mobile): Ubuntu 22.0.4
  • Link to your project:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant