简体   繁体   English

Docker jwilder / nginx-proxy位置配置

[英]Docker jwilder/nginx-proxy location configuration

I have 3 ( app-client,app-a, app-b )applications are running in jetty server and one NGINX load balancer ( app-lb). 我有3个(app-client,app-a,app-b)应用程序在码头服务器中运行,并且有一个NGINX负载均衡器(app-lb)。 All (internal or external) requests are coming to my application through load balancer. 所有(内部或外部)请求都通过负载平衡器到达我的应用程序。 Based on web context ( /app-a/ or /app-b/) name, LB will forward the request to the correct application. LB将根据Web上下文(/ app-a /或/ app-b /)名称将请求转发到正确的应用程序。 I have configured (location /app-a/ and location /app-b and location /app-client) in LB. 我已经在LB中配置了(位置/ app-a /和位置/ app-b以及位置/ app-client)。 app-a will call app-b and app-b will call app-a , app-client will be called from outside world, app-client will call app-a or app-b. app-a将呼叫app-b,而app-b将呼叫app-a,app-client将被外界呼叫,app-client会呼叫app-a或app-b。

I have written Docker-composer for my application. 我已经为我的应用程序编写了Docker-composer。 To avoid circular dependency, I have used Docker net. 为了避免循环依赖,我使用了Docker net。 it is working good. 运行良好。

If I scale up my application. 如果我扩大应用程序。 LB doesn't know about this new application container. LB不知道这个新的应用程序容器。

I have gone though few tutorials and trying to use jwilder/nginx-proxy instead of NGINX. 我花了很少的教程,尝试使用jwilder / nginx-proxy代替NGINX。 if I use that using VIRTUAL_HOST=app-name variable it is updating upstream in configuration file.But, My application is running based on location mapping for each container.if I don't specify, how request will go to correct container. 如果我使用VIRTUAL_HOST = app-name变量使用它,它将在配置文件中向上游更新。但是,我的应用程序是基于每个容器的位置映射运行的。如果我未指定,请求将如何转到正确的容器。

How to give location mapping in LB's default.conf file like below since this configuration updated by container dynamically or how to make internal call urls. 由于此配置由容器动态更新,因此如何在LB的default.conf文件中提供位置映射,如下所示, 或者如何进行内部调用网址。

   location /app-a {
            proxy_pass http://app-a;
    }
   location /app-client {
            proxy_pass http://app-client;
    }


   location /app-b {
            proxy_pass http://app-b;
    }
Request from outside: http://IP:9090/app-client/
Internal call : http://app-lb:80/app-a/
                http://app-lb:80/app-b

   LB exposed port no is 9090

There are pull requests (eg #599) for the nginx-proxy image to support virtual paths. 对于nginx代理映像有拉取请求(例如,#599)以支持虚拟路径。 To implement this, you can use the original image and just pass your own nginx.tmpl file into the container (as a volume mount, eg -v $(pwd)/nginx.tmpl:/app/nginx.tmpl:ro ). 要实现此目的,您可以使用原始图像,然后将自己的nginx.tmpl文件传递到容器中(作为卷挂载,例如-v $(pwd)/nginx.tmpl:/app/nginx.tmpl:ro )。 Then your containers just need to define VIRTUAL_PATH as they would VIRTUAL_HOST . 那么你的集装箱只需要定义VIRTUAL_PATH因为他们VIRTUAL_HOST

I'd also recommend setting DEFAULT_HOST on the nginx-proxy container and have everyone point to that if you don't want hostname based routing. 我还建议您在nginx-proxy容器上设置DEFAULT_HOST ,如果您不希望基于主机名的路由,请所有人都指出。

Note with #599, there's a bug in the nginx.tmpl that I ran into, you need to move {{ $networks := .Networks }} up two lines to be before the {{ range $container := .Containers }} (the range redefines . which redefines .Networks ). 请注意,在#599中,我遇到了nginx.tmpl中的一个错误,您需要将{{ $networks := .Networks }}向上移动两行,以将{{ range $container := .Containers }} (范围重新定义. ,重新定义.Networks )。 Otherwise all networks will be assumed reachable and you'll get timeouts if the container is also attached to other networks that nginx-proxy can't reach. 否则,如果容器也连接到Nginx-proxy无法访问的其他网络,则假定所有网络都是可访问的,并且您将超时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在jwilder / nginx-proxy Docker容器中重写URL - Rewrite URL in jwilder/nginx-proxy Docker container Docker - 如何通过 jwilder nginx-proxy 公开端口? - Docker - how to expose port thru jwilder nginx-proxy? Docker + jwilder/nginx-proxy + jwilder/docker-gen + jrcs/letsencrypt-nginx-proxy-companion + php:7-fpm + wordpress:fpm - Docker + jwilder/nginx-proxy + jwilder/docker-gen + jrcs/letsencrypt-nginx-proxy-companion + php:7-fpm + wordpress:fpm jwilder/nginx-proxy 与 cloudflare SSL 没有 - jwilder/nginx-proxy with cloudflare SSL doesnt jwilder/nginx-proxy 和 jrcs/letsencrypt-nginx-proxy-companion 后面的 docker 中的 gitea - gitea in docker behind jwilder/nginx-proxy and jrcs/letsencrypt-nginx-proxy-companion Docker 版本 1.13.1、Docker Swarm、jwilder/nginx-proxy 不会作为 docker 服务启动 - Docker version 1.13.1, Docker Swarm, jwilder/nginx-proxy will not start as a docker service 如何更改 docker jwilder/nginx-proxy 上传限制? - How can I change the docker jwilder/nginx-proxy upload limits? jwilder/nginx-proxy:最新原因 nginx https 代理 500 - jwilder/nginx-proxy:latest cause nginx proxy 500 for https 如何将 jwilder/nginx-proxy docker 映像中的日志发送到 logstash? - How can I send the logs from the jwilder/nginx-proxy docker image to logstash? 如何使用 jwilder/nginx-proxy 设置反向代理? - How to set reverse proxy using jwilder/nginx-proxy?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM