Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPM on a Swarm Cluster does not work well with more than one replica #4387

Open
borisruiz87 opened this issue Feb 23, 2025 · 2 comments
Open
Labels

Comments

@borisruiz87
Copy link

I'm trying to deploy NPM on a Docker Swarm Cluster. Everything works fine until I add more than one replica to the service.
The last test I did was using a remote MySQL and the /data files on an NFS. I set up a service with 3 replicas and there was no way to get it to be consistent.
My question is: is it possible to deploy an NPM service on a Docker Swarm cluster with more than one replica?
Does anyone have it in production?

This is my latest Stack:

version: '3.8'

services:
nginx-proxy-manager:
image: jc21/nginx-proxy-manager:latest
ports:

  • "80:80" # HTTP port
  • "81:81" # Management interface port
  • "443:443" # HTTPS port
    environment:
    DB_MYSQL_HOST: "ip"
    DB_MYSQL_PORT: "3306"
    DB_MYSQL_USER: "user"
    DB_MYSQL_PASSWORD: "pass"
    DB_MYSQL_NAME: "dbname"
    volumes:
  • /mnt/nfs/app:/data
  • /mnt/nfs/letsencrypt:/etc/letsencrypt
    networks:
  • dts-full-service-network
    deploy:
    replicas: 1
    placement:
    constraints:
  • "node.role==worker"

networks:
dts-full-service-network:
external: true

ONLY IF YOU HAVE A REPLICA IT WORKS WELL.
/mnt/nfs/ is an NFS

@WindoC
Copy link

WindoC commented Feb 24, 2025

I suggest to use original nginx for worker and leave the NPM one replica only.

My custom nginx image windoac/nginx-npm for worker to expose 80/443 ports and the NPM only expose 81 port for management.

It also improve the startup time that the NPM is quite big and startup very slow.

@borisruiz87
Copy link
Author

I suggest to use original nginx for worker and leave the NPM one replica only.

My custom nginx image windoac/nginx-npm for worker to expose 80/443 ports and the NPM only expose 81 port for management.

It also improve the startup time that the NPM is quite big and startup very slow.

Thanks for the suggestion.
In the end, I decided to use HAProxy as a Reverse Proxy. Considering that I use Docker Swarm, I inject the configuration with a Config in case I need to make any changes.

I leave my stacks in case anyone finds it interesting, although there is nothing transcendental in it:

version: '3.8'

configs:
haproxy_config:
file: ./haproxy.cfg
haproxy_certs:
file: ./certs.pem

services:
haproxy:
image: haproxytech/haproxy-alpine:latest
deploy:
replicas: 3
restart_policy:
condition: on-failure
placement:
constraints:
- "node.role==worker"
ports:
- "80:80"
- "443:443"
networks:
- dts-full-service-network
configs:
- source: haproxy_config
target: /usr/local/etc/haproxy/haproxy.cfg
- source: haproxy_certs
target: /usr/local/etc/haproxy/certs.pem

networks:
dts-full-service-network:
external: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants