docker-compose:Nginx容器代理到Couchdb容器

时间:2018-12-05 18:03:45

标签: docker nginx proxy couchdb

试图使用Nginx代理将组合设置组合到beddb。

我可以使它在VM环境中正常工作,但不能在docker中工作-主机上的curl到localhost:8085,我收到“(52)服务器的空回复”。日志输出中没有显示任何内容,容器的Nginx访问/错误日志中也没有显示任何内容。

这是我的docker-compose文件:

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;
  }
}

“ aph-coucdb”容器是从apache beddb映像派生的-它只包含我的local.ini文件(用默认配置替换apacheouchdb映像会显示相同的结果。)

端口5984在基本映像中公开,因此,在这里我不会对其进行公开(尽管我已经尝试过了。)如果我将端口条目添加到输出5984:5984的benchdb服务中,那么我可以与couchdb进行通信直接使用容器,一切似乎都很好。我还可以执行到nginx容器,并执行ping / curl aph-couchdb预期的结果。

这是我的Nginx配置:

select t1.av_transaction_id,
round(SUM((t1.gross_line_amount - t1.pos_discount_amount)), 2)    AS    total_amount_with_discount,
round(SUM((t1.gross_line_amount)), 2)    AS total_amount,
round(SUM((t1.pos_discount_amount)), 2) AS total_discount,
round(SUM((t2.gross_line_amount))/count(t1.gross_line_amount), 2) AS total_sales_tax
  from transaction_detail as t1 inner join
    transaction_detail as t2 on t1.av_transaction_id=t2.av_transaction_id
and t1.transaction_date=t2.transaction_date
where (t1.sku_id is not null or t1.line_action_display_descr='sold')
and t2.line_object_description='S6 Sales Tax'
and t1.av_transaction_id='581280193'
group by t1.av_transaction_id

已注释掉的条目是我根据其他研究尝试过的各种方法-没有作用-当我从主机卷曲localhost:8085时,我仍然从服务器收到(52)空答复。

似乎对此没有进一步的了解...

表示赞赏。 人力车

0 个答案:

没有答案