Traefik support for FQDN type server

Hi,
I am trying to understand whether Traefik supports servers of type FQDN. In the documentation the examples show IP addresses used as the servers.

Example:

## Dynamic configuration
http:
  services:
    my-service:
      loadBalancer:
        servers:
        - url: "http://<private-ip-server-1>:<private-port-server-1>/"
        - url: "http://<private-ip-server-2>:<private-port-server-2>/"

In my use case I would like to use a server which is an FQDN, where it shares multiple IPs.
Example:

$ nslookup fqdn-test.example.com

Non-authoritative answer:
Name:   fqdn-test.example.com
Address: 1.1.1.100
Name:   fqdn-test.example.com
Address: 1.1.1.101
Name:   fqdn-test.example.com
Address: 1.1.1.101
Name:   fqdn-test.example.com
Address: 1.1.1.101

In such case, Traefik should recognize the multiple IPs and load balance between them given a metric is configured.

The list of IPs may also change overtime so the DNS resolution should be refreshed.

Is there a way to achieve such capability with Traefik? If its not supported out of the box, can such capability be added via plugin development?

I guess special middleware will not help here as this is triggered on the router level, before transferring the traffic to the service.

Thank you,

Alexander

Hi @lexm

Traefik supports FQDN and IP addresses while creating a load balancer as part of a dynamic configuration.

By adding more IP addresses (record A) it will configure DNS round robin managed by DNS resolution on the server where Traefik is deployed. In that configuration, Traefik will not have an impact on what Ip address the request should be routed to, can't check what is the condition of the endpoint etc.

Is there any specific reason why you can add just more servers using LoadBalancer.server configuration:

## Dynamic configuration
http:
  services:
    my-service:
      loadBalancer:
        servers:
        - url: "http://1.1.1.100:80"
        - url: "http://1.1.1.101:80"

Hi @jakubhajek,

Thank you for our response.

The use case here, is that the DNS service here is a "smart service' where the IPs it provides for a specific FQDN can change over time.

For example in a case of auto scaling of servers which use DNS load balancing. Initially for a given FQDN we can have 3 servers and once load increases more servers will be added and the FQDN will now advertise the additional servers in such case, the load balancer should recognize the additional servers and load balance the traffic to those as well.

In such a case just adding the servers statically will not do. A workaround here may be to use an external service to perform periodically the DNS resolution and update the Traefik config. It will also need to take care of draining the servers which are being removed.

From your statement I understand it should be possible to set FQDN as server:

## Dynamic configuration
http:
  services:
    my-service:
      loadBalancer:
        servers:
        - url: "http://example.com:80"

So in such a case Traefik will use the local DNS resolved of the OS and if multiple servers are provided will load balance between them?
Is there some documentation regarding this functionality? For example, if the FQDN provides A and AAAA records, is there a way to force using only one type?

How would the refresh interval be controlled?