Can't use custom port on same subdomain only port 80 works file

hello,

i want use port 6001 on same subdomain as http like me.domain.com:6001, only works on port 80 and using entry points to mapping ports but same problem, this is my config

trafke docker-compose

version: '3.7'

services:
  traefik:
    image: traefik:v2.7
    container_name: traefik
    command:
      - --api.insecure=true
      - --api.dashboard=true
      - --api.debug=true
      - --log.level=DEBUG
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false
    restart: always
    security_opt:
      - no-new-privileges:true
    ports:
      - "80:80"
      - "8080:8080"
      - "6001:6001"
      - "6002:6002"
      - "9601:9601"
      - "9602:9602"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data/traefik.yml:/traefik.yml
      - ./data/acme.json:/acme.json
      # Add folder with dynamic configuration yml
      - ./data/configurations:/configurations
    networks:
      - external_network
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=external_network"
      - "traefik.http.routers.traefik-secure.entrypoints=web,websecure"
      - "traefik.http.routers.traefik-secure.rule=Host(`dash.domain.com`)"
      - "traefik.http.routers.traefik-secure.middlewares=user-auth@file"
      - "traefik.http.routers.traefik-secure.service=api@internal"

networks:
  external_network:
    external: true

trafiek.yml

api:
  dashboard: true


entryPoints:
  web:
    address: :80
  ws:
    address: :6001
  ws-api:
    address: :9601
  ws-api2:
    address: :9602
  ws2:
    address: :6002
  db:
    address: :5050
  websecure:
    address: :443


accessLog:
  filePath: "/configurations/access.log"


pilot:
  dashboard: false

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
  file:
    filename: /configurations/dynamic.yml


certificatesResolvers:
  letsencrypt:
    acme:
      email: admin@domain.com
      storage: acme.json
      keyType: EC384
      httpChallenge:
        entryPoint: web

  buypass:
    acme:
      email: admin@domain.com
      storage: acme.json
      caServer: https://api.buypass.com/acme/directory
      keyType: EC256
      httpChallenge:
        entryPoint: web

applications nginx and websocket socketi compose file

version: '3'
networks:
  external_network:
    external: true
  net_daf:
    driver: bridge

services:

  app:
    image: nginx:stable-alpine
    container_name: nginx_http
#    ports:
#      - "8083:80"
#      - "8082:80"
    volumes:
      - ./app/app1:/var/www/html/app1
      - ./app/app2:/var/www/html/app2
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - php
      - postgres
      - redis

    labels:
        - "traefik.enable=true"
        - "traefik.http.routers.nginx_http.rule=Host(`me.domain.com`,`test.domain.com`)"
        - "traefik.http.services.app.loadbalancer.server.port=80"
        - "traefik.http.routers.nginx_http.service=app"
        - "traefik.http.routers.nginx_http.entrypoints=web"
        - "traefik.docker.network=external_network"
    networks:
      - external_network
      - net_daf


  soketi:
    container_name: soketi_container
    image: quay.io/soketi/soketi:1.0.1-16-debian
    #network_mode: "host"
    #    ports:
    #      - "6001:6001"
    #      # - "6002:6002"
    #    #      - "9601:9601"
    volumes:
      - ./app/app1/soketi/config.json:/config.json
    command: "--config=/config.json"
    networks:
      - net_daf
      - external_network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.soketi.rule=Host(`me.domain.com`)"
      - "traefik.http.services.soketi.loadbalancer.server.port=6001"
      - "traefik.http.routers.soketi.entrypoints=ws,ws-api"
      - "traefik.http.routers.soketi.service=soketi"
      - "traefik.docker.network=external_network"

and this pic from traefik dashboard all ports exposed, only port 80 works from http request on domains

thanks

In general it looks ok. You have the ports mapped to the container inside, you have a Traefik entrypoint on the port and you have a router with the entrypoint assigned.

It seems you don't have TLS enabled on the port, you need to assign the certresolver to the entrypoint or to the router if https is used.

## Dynamic configuration
labels:
  - traefik.http.routers.blog.rule=Host(`example.com`) && PathPrefix(`/blog`)
  - traefik.http.routers.blog.tls=true
  - traefik.http.routers.blog.tls.certresolver=myresolver

See Traefik LetsEncrypt docs.

but i don't need https the service works on http and port 6001, the main problem is any custom port like 6001 , 6002 etc.. not working from http request only port 80 is works fine

Okay, same old mistake: you have Traefik command and traefik.yml, but you can only use one of them, not both together.

i notice that and disable it, although i think this is not the reason to deny traefik to let you using port with domain to access some service, really dunno what is the problem i tried everything still only port 80 works on domains

How does your config look now?

same, just i disabled Traefik command

Try enabling a single command if you have static config file mounted in root:

--configFile=/traefik.yml

same :frowning: even in traefik is fine and there is no errors time="2023-03-04T12:04:32Z" level=info msg="Configuration loaded from file: /traefik.yml" but told u the main problem can't use any custom port on domains like 6001 6002 8080 etc.. only port 80 works dunno why really weird !,


Try

netstat -tulpn

on the Linux command line of the host to see if the ports are opened.

yup checked that before, i disabled even Ubuntu ufw firewall, when curl on internal service works fine

but did you think nginx is the problem ? i config nginx server listen on port 80

server {
    listen 80;
    #listen 443 ssl;
    server_name dm.**.me;
    ..............
}

and this curl on domain and port

Usually Docker will handle the firewall automatically. nginx on port 80 is no problem, as it only listens inside the container, no ports declared.

Stop Traefik and see if the ports are not used anymore. Start Traefik to see if the ports are used. Check inside the Traefik container if the ports are used (docker exec - it <traefik-container> sh).

You can also stop everything and start a plain container on port 6001:

docker run --name nginx -p 6001:80 -d nginx

Then try to see if the port is accessible from the outside:

http://<ip-of-server>:6001/

sure, will works because was using docker without Traefik only with public ip and everything works like a charm, if you see in docker compose file i disabled ports below on soketi service cuz i mapping them in Traefik enrypointes but with Traefik nothing works only port 80

#      - "6001:6001"
#      - "6002:6002"
#      - "9601:9601"
#      - "9602:9602"

What does “not work” mean? What happens when you access those ports with a browser?

nothing happens just browser stay trying to reach it, only port 80 works fine and i can access nginx web applications

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.