apache / apache/couchdb-docker

Change port not working for reverse proxy

Open
#254 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Dockerfile
Stars
290
Forks
146
PR merge metrics
No merged PRs in 30d

Description

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

```yaml
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:

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.