The method that worked for me was to let Nginx proxy the /couchdb/_utils/
location to the standalone NPM version of Fauxton running inside a Docker container. All requests to /_utils
are thus not satisfied by the bundled CouchDB Fauxton, but instead by the standalone Fauxton server (that has the relevant fixes for subpath hosting).
Here are some hints for the steps required to make this work.
The NGINX configuration at /etc/nginx/conf.d/default.conf
:
upstream couchdb {
server app-couchdb:5984;
}
upstream fauxton {
server app-fauxton:8000;
}
server {
listen 80;
server_name localhost;
location /couchdb/_utils/ {
rewrite /couchdb/_utils/(.*) /$1 break;
proxy_pass http://fauxton/;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /couchdb {
rewrite /couchdb/(.*) /$1 break;
proxy_pass http://couchdb/;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
...
}
The CouchDB configuration at /opt/couchdb/etc/local.d/docker-1.ini
:
[chttpd]
bind_address = 0.0.0.0
[httpd]
enable_cors = true
bind_address = 0.0.0.0
The Dockerfile for the fauxton:alpine image at fauxton.dockerfile
:
FROM node:10-alpine
RUN npm install --silent -g fauxton
The docker configuration:
sudo docker build -t fauxton:alpine - < ./fauxton.dockerfile
sudo docker network create app-net
sudo docker create --name app-couchdb --network app-net --restart unless-stopped -v /opt/couchdb/etc/local.d/docker-1.ini:/opt/couchdb/etc/local.d/docker-1.ini -e COUCHDB_USER="$ADMIN_USER" -e COUCHDB_PASSWORD="$ADMIN_PASSWORD" couchdb:latest
sudo docker create --name app-fauxton --network app-net --restart unless-stopped fauxton:alpine fauxton --couchdb "http://app-couchdb:5984"
sudo docker create --name app-nginx --network app-net --restart unless-stopped --publish 8080:80 -v /etc/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf:ro nginx:alpine
sudo docker start app-couchdb
sudo docker start app-fauxton
sudo docker start app-nginx
That should more or less give you a setup with the latest version of CouchDB and the latest version of standalone Fauxton, all running inside Docker containers, and accessible via a non-root path at http://127.0.0.1:8080/couchdb/_utils/.
This solution will work for people who are having the following issues:
- https://github.com/apache/couchdb-fauxton/issues/1199
- https://github.com/apache/couchdb-fauxton/issues/944
- https://github.com/apache/couchdb-fauxton/issues/1188