Docker Community Forums

Share and learn in the Docker community.

Nginx proxy to couchdb


(Rickbsgu) #1

Trying to put together a compose setup using an nginx proxy to couchdb.

I can get this to work swimmingly well in a VM environment, but I can’t get it to work in docker - with curl on the host to localhost:8085, I get ‘(52) Empty reply from server’. Nothing is showing up in the log output, nor is anything showing in the nginx access/error logs in the container.

Here is my docker-compose file:

version: "3"
services:
  db.list-2-list:
    container_name: db.list-2-list.lcldev
    build: ./db.list-2-list/dev
    ports:
      - "8085:80"
    networks:
      - backend
      - frontend
    volumes:
      - ./db.list-2-list/dev/conf.d:/etc/nginx/conf.d

  couchdb:
    container_name: "aph-couchdb"
    image: "aph/couchdb"
    networks:
      - backend
    volumes:
      - cb-combined:/opt/couchdb/data

networks:
  backend:
  frontend:

volumes:
  cb-combined:
    external:
      name: "cb-combined"

The ‘aph-coucdb’ container is derived from the apache couchdb image - It just contains my local.ini file (substituting the apache couchdb image with default config shows the same results.)

Port 5984 is exposed in the base image, so I’m not exposing it here (although I have tried that.) If I add a ports entry to the couchdb service exporting 5984:5984, then I can talk to the couchdb container directly, and all seems fine with it. I can also exec into the nginx container, and ping/curl aph-couchdb with expected results.

Here’s my nginx config:

server {
  listen 80 default;
# listen [::]:80;
  location / {
    proxy_pass aph-couchdb:5984;
    proxy_redirect off;
#    proxy_set_header Host $host;
#    proxy_set_header X-Real-IP $remote_addr;
#    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#    proxy_set_header X-Forwarded-Host $server_name;
#    proxy_hide_header X-Powered-By;
    if ($request_method = OPTIONS ) {
      add_header 'Access-Control-Allow-Origin' '$http_origin';
      add_header 'Access-Control-Allow-Credentials' 'true';
      add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, HEAD, DELETE, OPTIONS';
      add_header 'Access-Control-Allow-Headers' 'X-Auth-CouchDB-UserName,X-Auth-CouchDB-Roles,X-Auth-CouchDB-Token,Accept,Authorization,Origin,Referer,X-Csrf-Token,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
      add_header 'Access-Control-Max-Age' 86400;
      add_header 'Content-Type' 'text/plain charset=UTF-8';
      add_header 'Content-Length' 0;
      return 204;
    }
  }

  location ~ ^/(.*)/_changes {
    proxy_pass aph-couchdb:5984;
  }
}

The commented out entries are various things I’ve tried based on other research - none make a difference - I still get the (52) Empty reply from server when I curl localhost:8085 from the host.

Can’t seem to get any further on this…

Thoughts appreciated.
rickb