Traefik: Bad Gateway in Swarm Mode deployed on Azure












1















I'm currently trying to deploy a set of microservices using Docker Swarm Mode. I've set up a traefik container and all my containers like this:



version: "3.4" 
networks:
backend-network:
external: true
services:

proxy:
image: traefik
command: --api --docker --docker.swarmMode --docker.watch
networks:
- backend-network
ports:
- "80:80"
- "8090:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints:
- node.role == manager

front-end:
image: *****
env_file:
- ./env/.react.env
networks: [ "backend-network" ]
ports:
- "8080:80"
deploy:
labels:
- traefik.enable=false
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints:
- node.role == manager

users-db:
image: *****
networks: ["backend-network"]
ports: [ "5984:5984" ]
deploy:
labels:
- traefik.enable=false
replicas: 1
restart_policy: # restart if something went wrong
condition: on-failure

# server that listens HTTP requests
users:
image: *****
env_file:
- ./env/.users.env
# wait until service db is up
depends_on: [ "users-db" ]
networks:
- backend-network
# - proxy
# expose port 80 of host node
expose:
- "80"
deploy:
labels:
- traefik.port=80
- traefik.docker.network=backend-network
- traefik.frontend.rule=PathPrefixStrip:/api/auth/
- traefik.backend.loadbalancer.swarm=true
- traefik.backend.loadbalancer.stickiness=true
replicas: 1


shop:
image: *******
env_file:
- ./env/.shop.env
depends_on: [ "users"]
networks:
- backend-network
# - proxy
expose:
- "80"
deploy:
labels:
- traefik.port=80
- traefik.frontend.rule=PathPrefixStrip:/api/shop
- traefik.docker.network=backend-network
- traefik.backend.loadbalancer.swarm=true
- traefik.backend.loadbalancer.stickiness=true
replicas: 1


checkout:
image: *****
env_file:
- ./env/.checkout.env
depends_on: [ "users", "shop" ]
networks:
- backend-network
expose:
- "80"
deploy:
labels:
- traefik.port=80
- traefik.frontend.rule=PathPrefixStrip:/api/checkout
- traefik.docker.network=backend-network
- traefik.backend.loadbalancer.swarm=true
- traefik.backend.loadbalancer.stickiness=true
replicas: 1


visualizer:
image: dockersamples/visualizer:stable
ports: [ "9000:8080" ]
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
labels:
- traefik.enable=false
placement:
constraints:
- node.role == manager


I hid the image names with ****.



I created two VM's on Azure, I created the Swarm, Traefik discovers my services but when I try to make a request with azure-dns/api/shop for example, it always returns Bad Gateway.



When using docker-compose up in local, it works fine. I did not try a Docker Swarm in local with docker-machine yet. I will soon.










share|improve this question



























    1















    I'm currently trying to deploy a set of microservices using Docker Swarm Mode. I've set up a traefik container and all my containers like this:



    version: "3.4" 
    networks:
    backend-network:
    external: true
    services:

    proxy:
    image: traefik
    command: --api --docker --docker.swarmMode --docker.watch
    networks:
    - backend-network
    ports:
    - "80:80"
    - "8090:8080"
    volumes:
    - "/var/run/docker.sock:/var/run/docker.sock"
    deploy:
    replicas: 1
    restart_policy:
    condition: on-failure
    placement:
    constraints:
    - node.role == manager

    front-end:
    image: *****
    env_file:
    - ./env/.react.env
    networks: [ "backend-network" ]
    ports:
    - "8080:80"
    deploy:
    labels:
    - traefik.enable=false
    replicas: 1
    restart_policy:
    condition: on-failure
    placement:
    constraints:
    - node.role == manager

    users-db:
    image: *****
    networks: ["backend-network"]
    ports: [ "5984:5984" ]
    deploy:
    labels:
    - traefik.enable=false
    replicas: 1
    restart_policy: # restart if something went wrong
    condition: on-failure

    # server that listens HTTP requests
    users:
    image: *****
    env_file:
    - ./env/.users.env
    # wait until service db is up
    depends_on: [ "users-db" ]
    networks:
    - backend-network
    # - proxy
    # expose port 80 of host node
    expose:
    - "80"
    deploy:
    labels:
    - traefik.port=80
    - traefik.docker.network=backend-network
    - traefik.frontend.rule=PathPrefixStrip:/api/auth/
    - traefik.backend.loadbalancer.swarm=true
    - traefik.backend.loadbalancer.stickiness=true
    replicas: 1


    shop:
    image: *******
    env_file:
    - ./env/.shop.env
    depends_on: [ "users"]
    networks:
    - backend-network
    # - proxy
    expose:
    - "80"
    deploy:
    labels:
    - traefik.port=80
    - traefik.frontend.rule=PathPrefixStrip:/api/shop
    - traefik.docker.network=backend-network
    - traefik.backend.loadbalancer.swarm=true
    - traefik.backend.loadbalancer.stickiness=true
    replicas: 1


    checkout:
    image: *****
    env_file:
    - ./env/.checkout.env
    depends_on: [ "users", "shop" ]
    networks:
    - backend-network
    expose:
    - "80"
    deploy:
    labels:
    - traefik.port=80
    - traefik.frontend.rule=PathPrefixStrip:/api/checkout
    - traefik.docker.network=backend-network
    - traefik.backend.loadbalancer.swarm=true
    - traefik.backend.loadbalancer.stickiness=true
    replicas: 1


    visualizer:
    image: dockersamples/visualizer:stable
    ports: [ "9000:8080" ]
    volumes:
    - "/var/run/docker.sock:/var/run/docker.sock"
    deploy:
    labels:
    - traefik.enable=false
    placement:
    constraints:
    - node.role == manager


    I hid the image names with ****.



    I created two VM's on Azure, I created the Swarm, Traefik discovers my services but when I try to make a request with azure-dns/api/shop for example, it always returns Bad Gateway.



    When using docker-compose up in local, it works fine. I did not try a Docker Swarm in local with docker-machine yet. I will soon.










    share|improve this question

























      1












      1








      1








      I'm currently trying to deploy a set of microservices using Docker Swarm Mode. I've set up a traefik container and all my containers like this:



      version: "3.4" 
      networks:
      backend-network:
      external: true
      services:

      proxy:
      image: traefik
      command: --api --docker --docker.swarmMode --docker.watch
      networks:
      - backend-network
      ports:
      - "80:80"
      - "8090:8080"
      volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      deploy:
      replicas: 1
      restart_policy:
      condition: on-failure
      placement:
      constraints:
      - node.role == manager

      front-end:
      image: *****
      env_file:
      - ./env/.react.env
      networks: [ "backend-network" ]
      ports:
      - "8080:80"
      deploy:
      labels:
      - traefik.enable=false
      replicas: 1
      restart_policy:
      condition: on-failure
      placement:
      constraints:
      - node.role == manager

      users-db:
      image: *****
      networks: ["backend-network"]
      ports: [ "5984:5984" ]
      deploy:
      labels:
      - traefik.enable=false
      replicas: 1
      restart_policy: # restart if something went wrong
      condition: on-failure

      # server that listens HTTP requests
      users:
      image: *****
      env_file:
      - ./env/.users.env
      # wait until service db is up
      depends_on: [ "users-db" ]
      networks:
      - backend-network
      # - proxy
      # expose port 80 of host node
      expose:
      - "80"
      deploy:
      labels:
      - traefik.port=80
      - traefik.docker.network=backend-network
      - traefik.frontend.rule=PathPrefixStrip:/api/auth/
      - traefik.backend.loadbalancer.swarm=true
      - traefik.backend.loadbalancer.stickiness=true
      replicas: 1


      shop:
      image: *******
      env_file:
      - ./env/.shop.env
      depends_on: [ "users"]
      networks:
      - backend-network
      # - proxy
      expose:
      - "80"
      deploy:
      labels:
      - traefik.port=80
      - traefik.frontend.rule=PathPrefixStrip:/api/shop
      - traefik.docker.network=backend-network
      - traefik.backend.loadbalancer.swarm=true
      - traefik.backend.loadbalancer.stickiness=true
      replicas: 1


      checkout:
      image: *****
      env_file:
      - ./env/.checkout.env
      depends_on: [ "users", "shop" ]
      networks:
      - backend-network
      expose:
      - "80"
      deploy:
      labels:
      - traefik.port=80
      - traefik.frontend.rule=PathPrefixStrip:/api/checkout
      - traefik.docker.network=backend-network
      - traefik.backend.loadbalancer.swarm=true
      - traefik.backend.loadbalancer.stickiness=true
      replicas: 1


      visualizer:
      image: dockersamples/visualizer:stable
      ports: [ "9000:8080" ]
      volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      deploy:
      labels:
      - traefik.enable=false
      placement:
      constraints:
      - node.role == manager


      I hid the image names with ****.



      I created two VM's on Azure, I created the Swarm, Traefik discovers my services but when I try to make a request with azure-dns/api/shop for example, it always returns Bad Gateway.



      When using docker-compose up in local, it works fine. I did not try a Docker Swarm in local with docker-machine yet. I will soon.










      share|improve this question














      I'm currently trying to deploy a set of microservices using Docker Swarm Mode. I've set up a traefik container and all my containers like this:



      version: "3.4" 
      networks:
      backend-network:
      external: true
      services:

      proxy:
      image: traefik
      command: --api --docker --docker.swarmMode --docker.watch
      networks:
      - backend-network
      ports:
      - "80:80"
      - "8090:8080"
      volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      deploy:
      replicas: 1
      restart_policy:
      condition: on-failure
      placement:
      constraints:
      - node.role == manager

      front-end:
      image: *****
      env_file:
      - ./env/.react.env
      networks: [ "backend-network" ]
      ports:
      - "8080:80"
      deploy:
      labels:
      - traefik.enable=false
      replicas: 1
      restart_policy:
      condition: on-failure
      placement:
      constraints:
      - node.role == manager

      users-db:
      image: *****
      networks: ["backend-network"]
      ports: [ "5984:5984" ]
      deploy:
      labels:
      - traefik.enable=false
      replicas: 1
      restart_policy: # restart if something went wrong
      condition: on-failure

      # server that listens HTTP requests
      users:
      image: *****
      env_file:
      - ./env/.users.env
      # wait until service db is up
      depends_on: [ "users-db" ]
      networks:
      - backend-network
      # - proxy
      # expose port 80 of host node
      expose:
      - "80"
      deploy:
      labels:
      - traefik.port=80
      - traefik.docker.network=backend-network
      - traefik.frontend.rule=PathPrefixStrip:/api/auth/
      - traefik.backend.loadbalancer.swarm=true
      - traefik.backend.loadbalancer.stickiness=true
      replicas: 1


      shop:
      image: *******
      env_file:
      - ./env/.shop.env
      depends_on: [ "users"]
      networks:
      - backend-network
      # - proxy
      expose:
      - "80"
      deploy:
      labels:
      - traefik.port=80
      - traefik.frontend.rule=PathPrefixStrip:/api/shop
      - traefik.docker.network=backend-network
      - traefik.backend.loadbalancer.swarm=true
      - traefik.backend.loadbalancer.stickiness=true
      replicas: 1


      checkout:
      image: *****
      env_file:
      - ./env/.checkout.env
      depends_on: [ "users", "shop" ]
      networks:
      - backend-network
      expose:
      - "80"
      deploy:
      labels:
      - traefik.port=80
      - traefik.frontend.rule=PathPrefixStrip:/api/checkout
      - traefik.docker.network=backend-network
      - traefik.backend.loadbalancer.swarm=true
      - traefik.backend.loadbalancer.stickiness=true
      replicas: 1


      visualizer:
      image: dockersamples/visualizer:stable
      ports: [ "9000:8080" ]
      volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      deploy:
      labels:
      - traefik.enable=false
      placement:
      constraints:
      - node.role == manager


      I hid the image names with ****.



      I created two VM's on Azure, I created the Swarm, Traefik discovers my services but when I try to make a request with azure-dns/api/shop for example, it always returns Bad Gateway.



      When using docker-compose up in local, it works fine. I did not try a Docker Swarm in local with docker-machine yet. I will soon.







      azure docker traefik






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 21:49









      ZynZyn

      62




      62
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Verify that backend-network is an overlay network.



          Then try first without



             - traefik.backend.loadbalancer.swarm=true
          - traefik.backend.loadbalancer.stickiness=true # especially this one


          It seems that sticky session is buggy in v1.7 according to issue 3770.






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309230%2ftraefik-bad-gateway-in-swarm-mode-deployed-on-azure%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Verify that backend-network is an overlay network.



            Then try first without



               - traefik.backend.loadbalancer.swarm=true
            - traefik.backend.loadbalancer.stickiness=true # especially this one


            It seems that sticky session is buggy in v1.7 according to issue 3770.






            share|improve this answer






























              0














              Verify that backend-network is an overlay network.



              Then try first without



                 - traefik.backend.loadbalancer.swarm=true
              - traefik.backend.loadbalancer.stickiness=true # especially this one


              It seems that sticky session is buggy in v1.7 according to issue 3770.






              share|improve this answer




























                0












                0








                0







                Verify that backend-network is an overlay network.



                Then try first without



                   - traefik.backend.loadbalancer.swarm=true
                - traefik.backend.loadbalancer.stickiness=true # especially this one


                It seems that sticky session is buggy in v1.7 according to issue 3770.






                share|improve this answer















                Verify that backend-network is an overlay network.



                Then try first without



                   - traefik.backend.loadbalancer.swarm=true
                - traefik.backend.loadbalancer.stickiness=true # especially this one


                It seems that sticky session is buggy in v1.7 according to issue 3770.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 19 '18 at 14:28

























                answered Nov 14 '18 at 22:41









                SiyuSiyu

                2,90311227




                2,90311227
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309230%2ftraefik-bad-gateway-in-swarm-mode-deployed-on-azure%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python