-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Docker Swarm Mode? #927
Comments
I have the following errors in swarm mode on one node only: upstream server temporarily disabled while connecting to upstream connect() failed (110: Connection timed out) while connecting to upstream Have you planned to support swarm mode ? |
works for me on swarm mode, but only with the it's possible the connection timeout is from the ingress network it tries to connect on. this was fixed back in August, hence, only available in the |
@kennethklee Did you try it with the proxy and applications in different stacks (deployed using docker stack deploy -c docker-compose.yml). This would be the ideal use case because you can deploy and remove individual stacks without messing with the proxy stack. |
@kennethklee Can you provide an example with compose file for a docker stack with multiple nodes? |
@biels Could you run nginx-proxy in swarm mode with docker stack? |
@arefaslani Did you figure out how to make it work on multiple nodes in Swarm mode. It only seems to connect to services on the same node. |
I found a service called traefik that does exactly the same and seems to
work a little bit better. However I'm seriously considering switching over
to kubernetes.
…On Mar 10, 2018 8:51 AM, "Aref Aslani" ***@***.***> wrote:
@biels <https://github.com/biels> Could you run nginx-proxy in swarm mode
with docker stack?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#927 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE64MCU0p8JWCc6n4BcRttH6QM6wr6rJks5tc4XrgaJpZM4PXgPe>
.
|
@loic294 All I did was forking the project and manually change this line to |
@arefaslani I almost changed everything for Kubernetes but got it to work with normal Nginx, but without this library. It's far from optimal but for my use case, it works great. In my
The placement is important because I manually uploaded the
Finally the
The cool thing about this is that the upstream server uses the service name to resolve the host. It then uses the internal load balancer to redirect the request to the best container. The super important part is that you need to expose the port of your app in the I really hope that nginx-proxy solves the issue because their solution is way cleaner. |
Checkout my image. It's written in javascript and will be developed easily. Pull requests are welcome 🙂 |
docker-gen type Network struct {
IP string
Name string
Gateway string
EndpointID string
IPv6Gateway string
GlobalIPv6Address string
MacAddress string
GlobalIPv6PrefixLen int
IPPrefixLen int
} So one solution is to change these lines in nginx-proxy template to support port through {{ else if .Network }}
# {{ .Container.Name }}
{{ if .Network.IP }}
{{ if .Container.Env.VIRTUAL_PORT }}
server {{ .Network.IP }}:{{ .Container.Env.VIRTUAL_PORT }};
{{ else }}
- server {{ .Network.IP }} down;
+ server {{ .Network.IP }}:{{ .Container.Env.VIRTUAL_PORT }};
{{ end }}
{{ else }}
server 127.0.0.1 down;
{{ end }}
{{ end }} Then rebuild the image and use |
Any updates? |
I am working on a solution for Meteor Up: nginx-proxy-swarm-upstream. |
@zodern This image works well with swarm mode. Formerly I created the nginx-autoconf to work with swarm mode. But then I realized that just by changing the original template and rebuilding, this image works well in swarm mode. |
Thanks @arefaslani. That should work for most apps. There are two main problems that nginx-proxy-swarm-upstream solves:
|
I end up wrote a customize nginx.conf file alone with |
@arefaslani , care to share examples of your service's configurations to make it work in swarm mode accross different nodes :) |
ConfigurationBuild your custom Nginx ProxyCreate a Dockerfile like this:
Copy nginx-proxy's nginx.tmpl alongside your docker file and change it as this comment. Then name and build your new proxy with the new template file. Docker Compose file
Like the example above add How does it workNOTE: All the things I write next is just to clarify what does these configs if you don't understand some parts. If you understand it, go and config yours. VolumesThere are 3 volumes in this compose file:
ServicesThere are 3 services in this compose file:
|
@arefaslani , thanks for sharing your work. However, your patch has drifted from the current state of the repo (which changed in this commit): Your patch: {{ else if .Network }}
# {{ .Container.Name }}
{{ if .Network.IP }}
{{ if .Container.Env.VIRTUAL_PORT }}
server {{ .Network.IP }}:{{ .Container.Env.VIRTUAL_PORT }};
{{ else }}
- server {{ .Network.IP }} down;
+ server {{ .Network.IP }}:{{ .Container.Env.VIRTUAL_PORT }};
{{ end }}
{{ else }}
server 127.0.0.1 down;
{{ end }}
{{ end }} Current (link pinned to a revision, for posterity): {{ else if .Network }}
# {{ .Container.Name }}
{{ if .Network.IP }}
server {{ .Network.IP }} down;
{{ else }}
server 127.0.0.1 down;
{{ end }}
{{ end }} How does this change figure in? |
This, based on @arefaslani's solution, seems to work so far: https://gist.github.com/jamiejackson/bac3a440975d1cd98c2d19cd96da1b56 It uses a patch in an attempt to be flexible with regard to updates of the base image. |
Has someone successfully implemented it with multiple node? For me when nginx-proxy needs to contact another node, it ends in a 503 Service Temporarily Unavailable. |
@jamiejackson @arefaslani does it also works with Kubernetes? |
@Divxtaman Unfortunately I didn't test it with Kubernetes. I've tested it with Docker Swarm. |
@jamiejackson Sorry for the late response. Yes I created this patch for myself almost a year ago. Thank you for updating it. But I think it's a better solution to create a pull request to solve this issue once for all. How about that? |
I seem to have the same issue on a single node. I have a pydio container connected with an ssl backend on port 443 (set the VIRTUAL_PORT and VIRTUAL_PROTO env vars accordingly). Works fine in docker compose but with docker stack deploy it fails to find a proper upstream (config shows the proper upstream but with a "down" flag). Likely has to do with "expose" being deprecated in docker swarm (ignored by docker stack deploy) and nginx failing to fall back on VIRTUAL_PORT. |
Got stuck with the same issues, finally used traefik. |
I was allready using Traefik as a reverse proxy traefik was perfect. But I occurred an issue with using signalr with traefik than I decided to go back to Nginx however I tried either solutions of @jamiejackson and @arefaslani. I could not achieve to run the proxy in my cluster (swarm mode). |
you saved my time that template looking monkaS to debug EZClap this is my custom fork https://github.com/tunailgaz/nginx-proxy repo working fine from evertramos/docker-compose-letsencrypt-nginx-proxy-companion |
Merge into master for this would be great! |
Apologise if I revive this here but many post referenced this post. The current version of nginx.tmpl does look different from this. Anyone have a working version? With the current version, the proxy is still showing only the local connected container, instead of all the replica containers in the swarm. |
@daveteu this PR has never been merged into the project. As the Japanese would say, akiramete (give up) ...Seems the project maintainer would rather this project fall into obscurity than to accept contributions from the community. I switched to Traefik for swarmed environments. While it is a beast to understand at first, it works perfectly under swarms. |
thanks @bkraul , didn't know this project is outdated. I wanted nginx to dynamically add upstreams so I can easily scale without touching and changing the "upstream" bit + caching. Traefik fills over complicated and i still need to add nginx nevertheless to do the caching bit (where i have custom lua to do purging). I wonder if this will work for kubernetes. i just haven't moved to kubernetes because of the VPS requirements. |
@daveteu Not to do any unfair advertising, but +1 for traefik. I too switched to that project after finding no workarounds for problems with this project and traefik is powerful but lightweight, so don't worry about "overkill". I literally just use it for reverse proxying ~10 containers on my personal VPS and it hasn't let me down in the slightest so far. |
@orangelynx @bkraul thank u, after struggling for a bit, managed to get traefik up and running! May I ask, if I want to put up a nginx cache infront of traefik, my nginx upstream proxy_pass can be any of my 3 servers IP that are behind traefik am i right? The swarm will auto load balance so long the host matches service-name.loadbalancer ? |
Does this fix the issue? 97a5dec?branch=97a5dec57a6e33a3d4dd93ab22a52c0fffcc0872&diff=split It definitely breaks my old patch so I'm hoping I can go without the patch now. |
Duplicate of #97 |
Is there any support for Docker Swarm Mode yet?
The text was updated successfully, but these errors were encountered: